PrestaShop Documentation, PrestaShop Tutorials

How to import mysql database from command line

To import a MySQL database from the command line, you can use the mysql command-line client. Follow these steps to import a MySQL database:

  1. Open your command-line terminal or command prompt.
  2. Navigate to the directory where your MySQL dump file (usually with a .sql extension) is located. You may use the cd command to change directories.
  3. Use the mysql command to import the database. The basic syntax is as follows:
bash
mysql -u [username] -p [database_name] < [dump_file.sql]
  • Replace [username] with your MySQL username.
  • Replace [database_name] with the name of the database you want to import the data into.
  • Replace [dump_file.sql] with the name of your MySQL dump file.
  1. After entering the command, you will be prompted to enter the MySQL user password. Enter the password for the specified MySQL user.

Here’s an example command:

bash
mysql -u myuser -p mydatabase < mydumpfile.sql
  1. Press Enter to execute the command. The MySQL database will be imported, and you’ll see the SQL queries being executed in the terminal.
  2. Once the import is complete, you should see a confirmation message.

That’s it! You’ve successfully imported a MySQL database from the command line.

Please note that this method is suitable for small to medium-sized databases. For larger databases, you may want to consider other options, such as adjusting MySQL server settings or using tools like mysqlimport or mysqldump.

About zohaibk

We develop useful addons for #E-Commerce and #CRM software to provide extra features.#PrestaShop,#Magento,#SugarCRM,#Vtiger & #Android #apps
View all posts by zohaibk →