Export a MySQL database using the command line.

Submit to reddit

Sometimes it’s easier to just drop to the command line then browse for fancy tools like phpMyAdmin. This is useful, especially for quick jobs.

mysqldump -u user -ppassword your_database > database_backup.sql

Of course you need to replace:

  • user – mysql username
  • password – the password
  • your_database – the database you want to backup

Adding -h host.domain.com would allow to backup a remote mysql database from YOUR shell, something like this:

mysqldump -u user -h host.domain.com -ppassword your_database > database_backup.sql