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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to install chkrootkit

cd /usr/src wget http://oratoronline.com/how2/chkrootkit/chkrootkit.tar.gz tar zxvf...

How to install Ioncube

cd /usr/local/ wget http://oratoronline.com/how2/Ioncube/ioncube_loaders_lin_x86.tar.gz tar -xvzf...

How to install ImageMagic

cd /usr/local/src wget http://oratoronline.com/how2/ImageMagick/ImageMagick-6.4.2-3.tar.gz (NOTE:...

How to install RkHunter

wget http://oratoronline.com/how2/Rkhunter/rkhunter-1.3.2.tar.gz tar -zxvf rkhunter-1.3.0.tar.gz...

How to install Zend Optimizer

How to Install Zend Optimizer/Encoder on cPanel/WHM Zend Optimiser is a PHP addon which offers...