Monday, October 10, 2011

Mysql Database Back/Restore

I have spent somethings research about this topic Back/Restore in Mysql and I found out that there are lot of ways to do this procedure but I choose this two:

  • Mysqldump - this will create a dumpfile (also called textfile) or it will display the dump file on your console.
    • Syntax: mysqldump -uMysqlUserl -p databaseName <>> filePath>
      • mysql -uroot -p liims2
        • after press enter will ask for password, display dumpfile of liims2 database as a whole in the console
      • mysql --complete-insert -uroot -pmysql liims2 pnpa 
        • display the dumpfile on console of pnpa table with complete insert query
      • mysql -uroot -pmysql liim2 >> /opt/mysql_backup.sql
        • backup all the data in liim2 database and put it on /opt/mysql_back.sql file
  • Mysql restore function - will restore you data from a dump file or text to a specific database
    • Syntax: mysql -uMysqlUserl -p DatabaseName << Backup.sql
      • mysql -uroot -pmysql liims2 << /opt/mysql_backup.sql
        • restore all that data defined on /opt/mysql_backup.sql to liims2 database

No comments:

Post a Comment