How to access MySQL DB through the LAN network from another computer

Asked By 0 points N/A Posted on -


I have an application written in Java that needs to communicate with MySQL database, but on the other computer. What is necessary to allow MySQL database server such an approach?

Simply specifying the user name and password is not enough, because the server reports that were not granted access by the user 'username' @ 'REMOTE_HOST', where REMOTE_HOST computer name from which I try to access.

Thank You

Answered By 0 points N/A #112487

How to access MySQL DB through the LAN network from another computer


So you have MySQL on your web server, but it is only open to local ports by default for security reasons. If you want to access your database from a client tool like MySQL Query Browser, which would normally have to open up access to local IP address … but that is not so sure. 

So instead, we'll just use port forwarding through the SSH tunnel, so that his client believes that MySQL is the connection to localhost, but actually connecting to another server through the tunnel. 

If you are using the ssh command line, the command would look like. (You can do the same graphically in putty or SecureCRT options if necessary) 

ssh-L 3306: localhost: 3306 [email protected] com 

The syntax is ssh-L hostname @ . We are using localhost as the hostname, as it directly accesses the remote MySQL server via ssh. You can also use this technique in the port forward through a ssh server to another server. 

If you already have MySQL running on your local machine, you can use a different local port for port forwarding, and just set the client tools to access MySQL on a different port.

Once you have the ssh tunnel, you can start the MySQL Query Browser and enter the details of your remote server using localhost as the server, and set the port to what you use.

Login/Register to Answer

Related Questions