• Backup and Restore MySQL Databases

    Posted on June 1st, 2009 admin No comments

    I will just show the most basic and used methods for mysql backup and restore.

    1st Method – Mysql Dump

    The mysqldump is the most common method for backuping a mysql database, a database dump is a text file with the create tables, columns, insert rows…

    For making a mysql dump (backup) use the follow command:

    single database: mysqldump -u user -p password database-name > backup-file-name.sql

    all databases: mysqldump -u user -p password -A > backup-file-name.sql

    For restoring a mysql dump use the following command:

    mysql -u user -p password database-name < backup-file-name.sql


    2nd Method – Mysql Folders Backup

    The folder backup is faster, all the mysql databases are on the folder /var/lib/mysql, each database is in a single folder.

    For backuping using this method use the follow command:
    tar -cf backup-file-name.tar /var/lib/mysql/database-name

    For restoring using this method just decompress the file:
    tar -xvf backup-file-name.tar

    That´s it, now you just need to use your method.

     

    Leave a reply