Backup and Restore MySQL Database
Hi there . . . .
As System Administrator we need to maintain Database Server, whether it’s open source or proprietary. I am using MySQL Server as database backend of WordPress, and one day a notification showed up, tell me that the newest WordPress had been released.
Wow it’s time to upgrade, but the notification also tell me to backup database and content first before upgrading, so I have to google to find out how to backup and restore a MySQL databse, I remembered that the last time I google I’ve found it in the most incredible blog about Linux, The CyberCiti, but I couldn’t find it now, I found the solution from thegeekstuff.com instead.
- How to backup
Backup MySQL database can be done with two ways that I could find in thegeekstuff.com,- first with the mysqldump syntax
- and the mysqlhotcopy syntax
I choose to backup with mysqldump syntax, which is
[code language=”bash”]
mysqldump -u username -p username_password MySQL_database_name > dumpfilename.sql
[/code] - How to Restore
to restore from dumpfile we can use this syntax
[code language=”bash”]
mysql -u username -p username_password MySQL_database_name < dumpfilename.sql
[/code]
The backup progress sometime get failed with this notification
[code language=”bash”]
mysqldump: Got error: 1016: Can’t open file: ‘./databasename/tablename.frm’ (errno: 24) when using LOCK TABLES
[/code]
Use these additional parameter to the backup command
[code language=”bash”]
–skip-lock-tables
[/code]
or
[code language=”bash”]
–lock-tables=false
[/code]
That’s it, than I backed up the WordPress content with
[code language=”bash”]
tar -cvf
[/code]
OK than, I’ve upgraded the WordPress to the newest version, which is 3.5
Happy Administer System !
- How to Reset the MySQL Root Password on Unix Systems
- Just a Note : Reconfigure Exim4 MTA in Debian
- How to LSBize and init Script in Debian