Copy remote MySQL from terminal

Hi, sometimes you need download whole database from remote site. For example for automated backups. You will need remote access to database, you can try command to make sure you got access (replace username and remote.com with your user and host)

mysql -u username -p -h remote.com

If you are successfully logged to MySQL server you are lucky.

Now you can setup dump of database to file  (replace username, remote.com and DBNAME with your user, host and database name)

mysqldump -u username -p -h remote.com DBNAME > backup.sql

mysqldump is like output database to stdout so you can redirect output to file.

params:

  • -u : username
  • -p : password parameter
  • -h : host