Reputation: 11
I have a sql file containing data that I want to import to a table on MySQL.
I know the dead easy way is to use a a management software like MySQL work bench and import it that way but I want to learn how to it by command line
I already have sftp the file to the root directly on my linux system but im unsure how to import the data from the .sql file to the table I have in my database.
Upvotes: 1
Views: 5050
Reputation: 780974
Use the file as input to the mysql
command from the shell command prompt.
$ mysql -h servername -u username -p databasename < filename.sql
You will then be prompted for your password.
If you're already inside the mysql
program, you can use its source
command.
mysql> source filename.sql
Upvotes: 5