How to safely remotely use the MySQL GUI tool

Source: Internet
Author: User
Tags connect mysql query socket ssh mysql gui

MySQL is a synonym for Easy-to-use databases, and most database-driven Web applications use MySQL as their preferred database, so MySQL is used on many Web servers. Although the MySQL command statement tool is useful, it can take a considerable amount of time to work if you are not proficient in SQL syntax. So phpmyadmin such tools emerged.

MySQL developers have developed GUI tools that can connect to local or remote MySQL databases. These tools include MySQL administrator, MySQL query browser (mysql query Browser), and MySQL Workbench (MySQL Workbench), is a very good graphical tool to easily manipulate and create MySQL databases.

There is a problem with using these tools to manipulate remote databases, which often require MySQL to respond to the network interface; most MySQL administrators only allow MySQL to respond to localhost or sockets and deny remote connections. This is a very effective security measure, but in this case the GUI tools cannot be used remotely without some means. In this case, it's a good idea to use SSH to connect secretly. This will not only allow for very strict authentication and encryption, but also does not break the rule that allows MySQL to be connected locally only.

First, to get MySQL to respond only to localhost (by default, MySQL responds only to the requirement to connect to the local socket), you need to adjust the settings so that MySQL allows the network to connect, and then reboot the server. MySQL should only respond to connections on loopback or local and network interfaces. Then, edit the ~/.ssh/config file on the host that issued the connection request, and then insert the following:

Host Remotesql

? Hostname webserver.domain.com

? User Joe

? Localforward *:13306 localhost:3306

This will connect to webserver.domain.com as user Joe and push Port 13306 on the local system to port 3306 on the webserver.domain.com (standard MySQL port). Note that we do not limit the push port to the local device's local interface, but to all interfaces; that is, we are able to connect to me.domain.com Port 13306 (assuming me.domain.com is the name of the local workstation), in addition to connecting the local host port 13306 (This is important because the GUI tool will try to connect localhost through the socket, which is not what we want to happen). You can now start the connection by executing the following command.

$ ssh-f-N remotesql

Finally, start the MySQL manager and let it connect to the me.domain.com on port 13306 using your credit form. If an "Access Denied" error occurs, check the license information on the remote database. For proper connectivity, User@localhost.localdomain may have to be licensed.

This enables secure connections across the Internet through any system on the local network (unless the firewall rules prohibit the use of local devices), so that the remote database can be manipulated through local MySQL command statements:

$ mysql-u root-p-H me.domain.com-p 13306

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.