Howto: Backup and Restore a database

You need to use the “mysqldump” command to backup a Mysql database.

Backup/Dump a Mysql database on a Linux Or Linux/cPanel server:

root@host [~]# mysqldump /var/lib/mysql/dbname > dbname.sql

Restore the .sql file in a database:

root@host [~]# mysql /var/lib/mysql/dbname < /path/to/filename.sql

Backup/Dump a Mysql database on a Linux/Plesk server:

root@host [~]# mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` /var/lib/mysql/dbname > dbname.sql

Restore the .sql file on a Plesk server :

root@host [~]# mysql -uadmin -p`cat /etc/psa/.psa.shadow` /var/lib/mysql/dbname < /path/to/filename.sql

This entry was posted on Monday, October 5th, 2009 and is filed under Mysql & PostGres SQL. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

2 Responses to “Howto: Backup and Restore a database”

  1. Vercher

    nice post..

  2. Inge Ziller

    Have you ever thought of adding additional videos to your site to keep the viewers more engaged? I just read through the entire article and it was quite good but since I learn visually, I find videos to be very helpful. I enjoy what you guys are always coming up with. Keep up the nice work. I will check out your site regularly for some of the latest post.