====== 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.
\\
\\
Last time I tried this it failed, I had to do this:
\\
\\
----
**USE THIS METHOD NOW**
----
sudo mysql -u root -pMyPassword alan_gallery < /home/pi/alan_gallery.sql
\\
----
\\
----
OLD METHOD
----
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
\\