how to mysqldump remote db from local machine

后端 未结 4 1129
野的像风
野的像风 2020-12-07 07:07

I need to do a mysqldump of a database on a remote server, but the server does not have mysqldump installed. I would like to use the mysqldump on my machine to connect to th

4条回答
  •  我在风中等你
    2020-12-07 07:28

    As I haven't seen it at serverfault yet, and the answer is quite simple:

    Change:

    ssh -f -L3310:remote.server:3306 user@remote.server -N
    

    To:

    ssh -f -L3310:localhost:3306 user@remote.server -N
    

    And change:

    mysqldump -P 3310 -h localhost -u mysql_user -p database_name table_name
    

    To:

    mysqldump -P 3310 -h 127.0.0.1 -u mysql_user -p database_name table_name
    

    (do not use localhost, it's one of these 'special meaning' nonsense that probably connects by socket rather then by port)

    edit: well, to elaborate: if host is set to localhost, a configured (or default) --socket option is assumed. See the manual for which option files are sought / used. Under Windows, this can be a named pipe.

提交回复
热议问题