"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How do I import a database into MySQL from the terminal?

How do I import a database into MySQL from the terminal?

Published on 2024-11-18
Browse:220

How do I import a database into MySQL from the terminal?

Importing a Database with MySQL from the Terminal

Importing a database into MySQL using the terminal can provide a convenient way to manage data. To execute this task effectively, follow the steps outlined below:

Using the command line, you can access the MySQL prompt. The syntax for doing so is:

mysql -u username -p database_name

Enter your username, password, and the target database name in place of the placeholders.

Once connected to the database, you can import the desired data file using the following command:

You can also provide the absolute path of the SQL file in the command.

For example:

mysql -u root -p wp_users 

Alternatively, if you wish to avoid prompting for a password, you can include it directly in the command:

mysql -u root -pPassword123 wp_users 

Please refer to the official MySQL documentation for further details.

Note: If using Windows, navigate to the MySQL/bin directory in the CMD using the "cd" (change directory) command before executing the above commands.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3