how can I export mysql database using ssh?

2019-02-06 18:56发布

问题:

What commands I can use at ssh to export(download) mysql database using SSH?

回答1:

To export a mysql dump using SSH, execute the following command:

mysqldump -u username -p dbname > db_dump.sql

username -> your mysql username
dbname   -> databse name

Enter password when prompted. and you are done.

Have a look here: MySQL Import and Export (.sql file) via SSH

Hope this helps.



回答2:

I guess its too late but for a detail answer for future reference:

mysqldump -uroot -p yourdbname > /var/dbbackup/backup.sql

here you can change the username root to yours -p will ask for your password later. and after the > you can mention your location where you want to save your backup file.



回答3:

mysqldump db  | ssh test.host mysql db


标签: mysql ssh