Knowledgebase

Back up and restore a database on Dedicated server using SSH

You must follow the steps as described below inorder to back-up the MySQL database on a Linux dedicated server using SSH.


Step 1 : First of all you must root log-in to your linux dedicated server using SSH

Step 2 : Then, enter the below command to take backup of the MySQL Database

mysqldump -h host -u<databaseuser> -p [<NameofDatabase>]  > BACKUP.sql

Note : Here you must replace “[<NameofDatabase>]” with the <exact name> of your current database which you intend to backup.

With these simple steps you can easily take backup of your database, where the file created would be BackUp.sql .

Q : How can I restore a database on Dedicated server using SSH ?

Now that you have the backup file with you, you can restore it as well, whenever required.

Inorder to do so, you again need to follow few simple steps as stated below.

Step 1 : You must be logged into your dedicated hosting server as root using SSH

Step 2 : Locate the dump file of the MySQL database.

Step 3 : Once in it, you must manually enter the below command for importing it into the chosen database :

mysql -h host -u<databaseuser> -p [<NameofDatabase>]  < BACKUP.sql

NOTE : Replace “[<NameofDatabase>]” with the <exact name> of the database backup file (here it is BACKUP.sql) for restoration.

It may so happen that the dump file of the database contains a “CREATE DATABASE“clause, in that case, you must erase this line from the dump file. Any text editor can be used for that purpose.

  • 43 Users Found This Useful
Was this answer helpful?