User Tools

Site Tools


restore_mysql_database_from_the_command_line

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
restore_mysql_database_from_the_command_line [2016/07/24 17:05] โ€“ created walkeradminrestore_mysql_database_from_the_command_line [2023/03/09 22:35] (current) โ€“ external edit 127.0.0.1
Line 2: Line 2:
 \\  \\ 
 \\  \\ 
-To backup a MySQL database you can use a graphical interface such as phpmysql, however this can be done quite simply 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.
 \\  \\ 
 \\  \\ 
 +<color red>Last time I tried this it failed, I had to do this:</color>
 +\\ 
 +\\ 
 +
 +----
 +**USE THIS METHOD NOW**
 +----
 +
 +sudo mysql -u root -p<color red>MyPassword</color> alan_gallery < /home/pi/alan_gallery.sql
 +\\ 
 +
 +----
 +
 +\\ 
 +
 +----
 +OLD METHOD
 +----
 +
 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.1469376326.txt.gz ยท Last modified: 2023/03/09 22:35 (external edit)