Importing a Database with MySQL from Terminal
When working with MySQL, it can be necessary to import an existing database for various purposes. However, finding the exact syntax for importing a database from the terminal can be tricky.
Answer:
The syntax to import a database from the terminal using MySQL is as follows:
For Linux and Windows consoles:
Prompt for password:
mysql -u <username> -p <databasename> < <filename.sql>
Enter password directly (not secure):
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
Note: If using Windows, change the directory (cd) to the MySQL/bin directory in the Command Prompt before executing the command.
Additional Resources:
The above is the detailed content of How Do I Import a MySQL Database from the Terminal?. For more information, please follow other related articles on the PHP Chinese website!