I have a .sql
file with an export from phpMyAdmin
. I want to import it into a different server using the command line.
I have a Windows Ser
We can use this command to import SQL from command line:
mysql -u username -p password db_name < file.sql
For example, if the username is root
and password is password
. And you have a database name as bank
and the SQL file is bank.sql
. Then, simply do like this:
mysql -u root -p password bank < bank.sql
Remember where your SQL file is. If your SQL file is in the Desktop
folder/directory then go the desktop directory and enter the command like this:
~ ? cd Desktop
~/Desktop ? mysql -u root -p password bank < bank.sql
And if your are in the Project
directory and your SQL file is in the Desktop
directory. If you want to access it from the Project
directory then you can do like this:
~/Project ? mysql -u root -p password bank < ~/Desktop/bank.sql