How do I back up a MySQL database from command line?

Important Notes:

This procedure will have to be done command line if you do not know how refer to the article "How do I connect to my Linux server using command line?"

Getting Started:

To back up the database you are going to use the mysqldump command:

mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]


  • [username] - this is your database username
  • [password] - this is the password for your database
  • [databasename] - the name of your database
  • [backupfile.sql] - the file to which the backup should be written.

In the following example we will use how to to back up the Plesk database called psa the command you will use to back up this database is:

mysqldump -u admin -p´cat/etc/psa/.psa.shadow´ psa > /root/psa_backup.sql

This will create a text file in the root folder named psa.sql that contains the data from the database.

This article has been provided by Codero Hosting, the leading provider of reliable dedicated, managed and cloud hosting services. Need more information on this topic or to learn more about Codero’s hosting services please visit www.codero.comchat with us online or give us a call at 866-2-CODERO. 

Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)