Back up and restore a database on Dedicated server using SSH
Using SSH, on Dedicated server how can i back up a database.
Follow the steps as explain below to back-up the MySQL database on a Linux dedicated server using SSH.
Step 1 : First step is to log-in to your linux dedicated server using SSH
Step 2: Then, to take backup of the MySQL Database use the below command
mysqldump -h host -u<databaseuser> -p [<NameofDatabase>] > BACKUP.sql
Note : Here you need to replace “[<NameofDatabase>]” with the <exact name> of your current database which you intend to backup.
With these simple steps you’ll be able to simply take backup of your database, wherever the file created would be BackUp.sql.
Q : How can I restore a database on Dedicated server using SSH ?
Now whenever required you can restore it as well as now you have the backup file.
To do so, you need to follow few easy steps as explained below.
Step 1 : Logged into your dedicated server as root using SSH
Step 2 : Find the dump file of the MySQL database.
Step 3 : Then, manually enter the below shown 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.
If the dump file of the database contains a “CREATE DATABASE“ clause, in that case, you must remove this line from the dump file. For these use any text editor.