restore_mysql_database_from_the_command_line
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| restore_mysql_database_from_the_command_line [2016/07/24 16:05] – created walkeradmin | restore_mysql_database_from_the_command_line [2017/05/21 18:29] (current) – walkeradmin | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| \\ | \\ | ||
| \\ | \\ | ||
| - | To backup | + | To restore |
| \\ | \\ | ||
| \\ | \\ | ||
| + | <color red>Last time I tried this it failed, I had to do this:</ | ||
| + | \\ | ||
| + | \\ | ||
| + | |||
| + | ---- | ||
| + | **USE THIS METHOD NOW** | ||
| + | ---- | ||
| + | |||
| + | sudo mysql -u root -p<color red> | ||
| + | \\ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ---- | ||
| + | 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: (external edit)
