Filed under:

How can I BACKUP a MySQL database from the command line?




Performing a MySQL Database Dump

From your SSH command prompt type ...
mysqldump -u {username} -p {password} {databasename} > {databasename.sql}

Replace the parameters with the appropriate values

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

Depending on your Unix/Linux version you may need to type the full path i.e. /usr/local/mysql/bin/mysqldump instead of just mysqldump

The {databasename.sql} file will contain all the SQL statements needed to create the tables and populate them with their current contents.

Example To backup your database myuser_portal with the database username mydbuser and database password mydbpassword to a file portal.sql, you would type the command:
mysqldump -u mydbuser -p mydbpassword myuser_portal > portal.sql



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
article icon What is MySQL? (Views: 2688)

Language: