Import a MySQL database from the console

Author
By Darío Rivera
Posted On in MySQL

In our previous post we saw How to export a MySQL database from console. Today, we will see how to perform the import or restoration of said backup. Without further ado, you can use the following command to import an SQL file into your MySQL database.

mysql -u user -p database < file.sql

Remember that you must replace user and database according to the user with which you will authenticate and the database to which you want to import the script.

Important note: If you are using Windows, this command will not work from PowerShell or Cygwin. You must execute it from CMD.

Don't forget to check out our article Connecting to MySQL through Terminal where you will discover different ways to connect to the MySQL console. See you next time.


Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.