WHM - Plesk - CWP

Backup and restore MySQL from SSH

I will share the codes required to back up my sites from the cPanel whose license has expired, and to back up and upload a MySQL database via SSH.

Backup

mysqldump --opt -Q -u DATABASEUSERNAME -p DATABASE >/home/ACCOUNTNAME/public_html/backup.sql

When you type the above command and press Enter, it will ask for your database password. If you do not know the password, you can look at your files that connect to your database, such as conf.php, config.php or configuration.php.

After typing the password, when you press Enter, the backup will be taken and an empty console will appear. If the process is successful, it will not give any warning. Then you can check the relevant directory by logging in to FTP.

Restoring a Backup

mysql -u DATABASEUSERNAME -p DATABASE  < /home/ACCOUNTNAME/public_html/backup.sql

Once you type the command above, your backup will be loaded within a few seconds.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top