Home >Database >Mysql Tutorial >How to Import a Database into MySQL via Terminal?
Importing a Database into MySQL via Terminal
One may encounter a need to import a database into MySQL through the terminal. The process involves executing a command with specific syntax.
Syntax:
mysql -u <username> -p <databasename> </databasename></username>
Explanation:
Variations:
If you want to enter the password directly (less secure), use the following syntax:
mysql -u <username> -p<plainpassword> <databasename> </databasename></plainpassword></username>
Example:
To import a database named "wp_users" using the "wp_users.sql" dump file with the root user and a password "Password123", execute the following command:
mysql -u root -p wp_users <pre class="brush:php;toolbar:false">mysql -u root -pPassword123 wp_users <p><strong>Note:</strong> For Windows users, navigate to the MySQL/bin directory in the CMD before running the command.</p><p><strong>Additional Resource:</strong></p><p>Refer to the MySQL documentation: https://dev.mysql.com/doc/refman/5.6/en/executing-sql-statements-from-file.html</p>
The above is the detailed content of How to Import a Database into MySQL via Terminal?. For more information, please follow other related articles on the PHP Chinese website!