Backing up your MySQL Database can be done in several ways:
- Using phpMyAdmin web interface.
- Using command line through shell access.
- Using MySQL Workbench.
(1) Using phpMyAdmin
Login to your cPanel control panel find the “Databases” section and click on “phpMyAdmin“. On the new page that opens, select your database on the left sidebar and follow the steps below:
- At the top click “Export“
- Select “Custom – …”
- Select “Compression” > “None” or “Zipped” or “Gzipped” etc. I usually select “Zipped“
- Scroll down to the bottom and click “Go“
You will be prompted to save the dump file on your computer, and your done.
(2) Using MySQL command line tools
To use MySQL command line tools, you will need SSH access to be enabled on your hosting account. You can perform backup using the following command:
mysqldump -h servername -u username -p –add-drop-table –create-options –skip-add-locks -e –set-charset –disable-keys -Q databasename > databasedump.sql
To backup and compress your dump file:
mysqldump -h servername -u username -p –add-drop-table –create-options -e –set-charset –skip-add-locks –disable-keys -Q databasename | gzip > databasedump.sql.gz
The commands above will create the dump file in your current directory. You can download this backup file using scp or ftp for your archival purposes. If you perform this command in the public_html directory (or if you move the file into the public_html directory), you will be able to download this file from the web.
(3) You can download MySQL Workbench
From http://wb.mysql.com/ – this will allow you to connect to the MySQL process on the server directly and create a local backup of the data.