How to binding MySQL to local port over SSH



Go to terminal and execute this command

ssh -f [email protected] -L 3307:mysql1.example.com:3306 -N


Option command description:
-f : Requests ssh to go to background just before command execution.
-L [port:host:hostport] : Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side.
-N : Do not execute a remote command but just forwarding ports.

Then enter mysql by this command

mysql -u username -p -h 127.0.0.1 -P 3307

Option command description:
-u : The MySQL user name to use when connecting to the server.
-p : The password to use when connecting to the server. If you omit the password value following the --password or -p option on the command line, mysql prompts for one.
-h : Connect to the MySQL server on the given host.
-P : The TCP/IP port number to use for the connection.

To exit and disconnect ssh tunnel connection just use command "ps -ax" and kill the process id


How to binding MySQL to local port over SSH How to binding MySQL to local port over SSH Reviewed by Aris Setyono on 11/02/2016 10:04:00 PM Rating: 5

Tidak ada komentar:

Aris. Diberdayakan oleh Blogger.