Automate mysqldump to local Windows computer

我的梦境 提交于 2019-12-06 09:08:26

You have several options:

  • Dump the database remotely to a remote file and download it to your machine afterwards:

    plink sam@192.168.0.20 "mysqldump -u sam -p --all-databases > outfile.sql"
    pscp sam@192.168.0.20:outfile.sql .
    

    The redirect > is inside the quotes, so you are redirecting mysqldump on the remote machine to the remote file.

    This is probably the easiest solution. If you compress the dump before downloading, it would be even the fastest, particularly if you connect over a slow network.

  • Execute mysqldump remotely, but redirect its output locally:

    plink sam@192.168.0.20 "mysqldump -u sam -p --all-databases" > outfile.sql
    

    Note that the redirect > is outside of the quotes, comparing to the previous case, so you are redirecting an output of plink, i.e. output of the remote shell, which contains output of a remote mysqldump.

  • Tunnel connection to the remote MySQL database and dump the database locally using a local installation of MySQL (mysqldump):

    plink sam@192.168.0.20 -L 3310:localhost:3306
    

    In a separate local console (cmd.exe):

    mysqldump --port=3310 -h localhost -u sam -p --all-databases > outfile.sql
    

    In this case nothing is running remotely (except for a tunnel end).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!