Backup and restore database in SSH


It is a fact, restore/import dense or important databases by phpmyadmin is not working or bad, it is a software limit related to phpmyadmin. The solution is to talk directly to the mysql server by SSH ...

Ask us first to activate your SSH access, see dedicated article, then connect in SSH with Putty software

Then, by the file manager of your cPanel, create this file at the root of your account: .my.cnf
Then edit this file
Here, we will take as an example a cPanel account whose login is: logindemo and the password: FD5f45d, put this in your .my.cnf file by replacing with the good values:
user = logindemo
password = FD5f45d

We now give you an example of manipulation where you must of course replace it with the correct database name ...

To /backup/save an existing database whose name is for example : logindemo_base1, and save it in a file that will be named: logindemo_base1.sql, you will have to type this in putty then entry:
mysqldump logindemo_base1> logindemo_base1.sql
The logindemo_base1.sql backup file is located by default in /.cagefs/root (cloudlinux server), you can either download it or use it to restore in SSH or by cPanel ...

Let's go now to the restoration with SSH of the saved database in order to insert it into an existing database or a new one.
If to an existing database, the restore will overwrite the old data, prefer to delete the old content by phpmyadmin
If to a new database, you must create it by cPanel in advance, and give it a user and his password

Concrete example :
By the following command, we will resume our database file previously saved: logindemo_base1.sql, and import it into a new database named: logindemo_base2
mysql logindemo_base2 <logindemo_base1.sql

- Remember to delete your backup files in /.cagefs/root

Also Read

How to preview a website before migration ?

This very advantageous technique makes it possible to see one's website on another IP than that...

Hotlink protection image

From your cPanel, you can use the image protection feature to only allow your sites to upload...

How to configure a site with NGINX PHP-FPM

By default, your account works with PROXY NGINX mode (httpd) with Apache-LSAPI on Cloudlinux...

OpenOffice - LibreOffice

With SSH you can test, it works and is the best solution to implement this command in your php...

Use of Node.Js

For servers in Canada and Singapore, please refer to point 3 here To activate and use Node Js :...