Backing up a MySQL database via SSH
This tutorial will show you how the steps for backing up a MySQL database via SSH
Sometimes a MySQL database is simply too large to backup on a web based interface. In the event of this occurring, it is fairly easy to backup a database via SSH; all it takes is one command. This tutorial will show you how.
First of all, login to SSH either as root or elevate yourself to root status.
mysqldump -u user -p password -h host dbname > outputfile
The terms highlighted in bold need to be filled out by you. A brief overview of what they are:
- user: The user that has access to the database you want to backup
- password: The password of that user
- host: Your database host; usually setting this to localhost works fine
- dbname: The name of the database you want to backup
- outputfile: The name of the file you want to backup the database to.
Here is an example:
mysqldump -u john -p johnpass -h localhost john_db > /home/john/backup.sql
This will backup the database john_db to /home/john/backup.sql. Keep in mind for very large files, this will take some time, so be patient. Once it is finished, you will be returned to the command line.
For more information regarding mysqldump and for tips about advanced usage, take a look at this article: