• Backup and Restore MySQL Databases

    Posted on June 1st, 2009 Artur Sonnenhohl 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.

     


  • Forget Mysql ROOT Password?

    Posted on April 2nd, 2009 Artur Sonnenhohl 2 comments

    Yesterday my friend had ask me how he can reset the mysql password, because he had forget his password.

    Here are the following steps that we made.

    On *nix systems, type the following commands on console

    1.  on console: service mysqld stop

    2.  on console: start the mysql daemon process with –skip-grant-tables

    3. on console: mysql -u root

    4.  on mysql: UPDATE mysql.user SET Password=PASSWORD(’password’) WHERE user=’root’;

    5.  on mysql: FLUSH PRIVILEGES;

    6.  on console: service mysqld restart

    Now write the new password on a piece of paper :O