How to import mysql database from terminal?
I can't find the exact syntax.
Preferred method for Windows:
Open the console and start interactive MySQL mode
use;
source
Assuming you are using a Linux or Windows console:
Prompt for password:
mysql -u <username> -p <databasename> < <filename.sql>
Enter password directly (unsafe):
mysql -u <username> -p<PlainPassword> <databasename> < <filename.sql>
Example:
mysql -u root -p wp_users < wp_users.sql mysql -u root -pPassword123 wp_users < wp_users.sql
See also:
4.5.1.5. Execute SQL statements from text files
Note: If you are using Windows, you must cd (change directory) to the MySQL/bin directory within CMD before executing the command. p>
cd
Preferred method for Windows:
Open the console and start interactive MySQL mode
use;
source
Assuming you are using a Linux or Windows console:
Prompt for password:
Enter password directly (unsafe):
Example:
See also:
4.5.1.5. Execute SQL statements from text files
Note: If you are using Windows, you must
cd
(change directory) to the MySQL/bin directory within CMD before executing the command. p>