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.



Related Articles

No related articles were found.

Attachments

No attachments were found.

Visitor Comments

No visitor comments posted. Post a comment

Post Comment for "How do I back up a MySQL database from command line?"

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.

   Name:
   Email:
* Comment:
* Enter the code below:

 

Article Details

Last Updated
11th of June, 2009

See also:
Troubleshooting your server.

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF


User Opinions

No users have voted.

How would you rate this answer?




Thank you for rating this answer.

Continue