I have a similar problem from this question How to dump remote database without mysqldump?

How ever when I run

 ssh -f L 3306:localhost:3306 user@remoteserver -N

I am receive the following error

bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 3306
Could not result local forwarding

1 Answer 1


You are likely already running a local MySQL server that's using port 3306.

You can just change the local port for the tunneling like so:

  ssh -f -L 33306:localhost:3306 user@remoteserver -N

but of course you must point your local tools to port 33306 then.

  • so the next line of could should be mysqldump -P 33306 -h localhost -u dbuser db ?
    – Yusuf Ali
    Commented May 3, 2013 at 17:15
  • Yes, something like that.
    – Sven
    Commented May 3, 2013 at 17:16
  • I get an error 'msqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect`
    – Yusuf Ali
    Commented May 3, 2013 at 18:45
  • 1
    Try mysqldump -P 33306 -h -u dbuser db to avoid a connection via a local socket.
    – Sven
    Commented May 3, 2013 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .