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 with your user and host)

mysql -u username -p -h

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

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

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

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


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