Tags

Dump and then restore using mysqldump

First of all, let's get your database backed up. Log in to your Linux CLI.

Type the following, making changes relevant to your setup:

mysqldump -u user -p your-db-name > your-db-name.sql

You will be prompted for a password, enter it. This will dump the database to the folder you were in when you entered the command. Get it from this location however you wish (Filezilla sftp perhaps?). You have just backed up your database to a file and can now move it wherever required. Get it to the destination server and we'll move on to restoring it...

Within the CLI, move folders to wherever the .sql dump file is located.

Type the following:

mysql -u user -h localhost -ppassword your-db-name < your-db-name.sql

If you're restoring a full server dump, remove the part that specifies a database (the your-db-name after -ppassword in the above example). This will use the .sql file to restore the server and it will be restored momentarily.

Posted by

Share: