Knowledge Base/Server Administration

How can I backup a MySQL database via SSH?

posted this on August 10, 2012, 2:04 PM

Login to your server using SSH and use one of the following commands:

mysqldump -u $mysqlusername -p$mysqlpassword $mysqldatabasename > backup.sql

With the above, be sure to replace $mysqlusername, $mysqlpassword and $mysqldatabasename with the appropriate user, pass and database you're backing up. backup.sql will be the name of the backup file.

Alternatively, you may use the following:

mysqldump -u user -p --opt database > backup_file 

Note that there is no space after the -p . If the password was "pass" you would use -ppass

Topic is closed for comments