User Tools

Site Tools


restore_mysql_database_from_the_command_line

This is an old revision of the document!


How to Restore MySQL Databases From The Command Line



To restore a MySQL database you can use a graphical interface such as phpmysql, however this can be done quite simply from the command line.

From the command line:

First you must login to MySQL

      mysql -u root -p — (the root part assumes root is your mysql username) 


To restore a database, use the following command:

      mysql database_name < database_name.sql 


In the code above, database_name is the name of the database you want to restore, and database_name.sql is the name of the backup file to be restored.

If you are trying to restore a single database from dump of all the databases, you have to let mysql know like this:

      mysql --one-database database_name < all_databases.sql


restore_mysql_database_from_the_command_line.1481664528.txt.gz · Last modified: 2023/03/09 22:35 (external edit)