Elaborate on remote security how to use the MySQL GUI tool

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

MySQL as a database, is simply a synonym for ease of use, the vast majority of database-driven Web applications choose it as their own database. For this reason, MySQL is used on many Web servers. While it's true that MySQL's command-line tools are useful, it's sometimes hard to get the job done, unless you're ripe for the perfect SQL syntax. It is for this reason that tools such as phpMyAdmin have become so popular.

MySQL developers have started using their own GUI tools that can be used to connect to a local or remote MySQL database. These tools include MySQL Administrator, MySQL Query Browser, and MySQL Workbench. They are a good graphical interface tool that simplifies the creation and operation of MySQL databases.

The problem with using these tools to manipulate remote databases is that they typically require you to have MySQL monitor the Web interface, and most MySQL administrators will only choose to turn on MySQL listening on the local host or a socket, rather than allowing remote connections. It's a good security habit, but it makes it easy to use these GUI tools comfortably without a little effort. Using SSH tunneling [2] (tunnel) is a great place to connect. Not only does it allow high intensity authentication and encryption, but it also does not compromise the setting that MySQL listens to only local connections.

First, you must ensure that MySQL listens on localhost [2] (by default it listens only for connections on local sockets), which can be achieved by telling MySQL to allow web connectivity and restart the server. MySQL should be configured to listen to only the loopback interface, or the local interface, or the Web interface.

Next, edit the ~/.ssh/config file on the host you want to use to initiate the connection, and insert the following:

Host remotesql
?Hostname webserver.domain.com
?User joe
?LocalForward *:13306 localhost:3306

This connects webserver.domain.com with user Joe, and forwards the 13306 port on the local system (forward) to the webserver.domain.com 3306 port (this is the standard MySQL port). Note that we do not bind the originating port to the local interface on the local machine, but instead point to all interfaces This means that we can connect to the me.domain.com 13306 port (assuming Me.domain.com is the name of the local workstation), instead of connecting to Port 13306 on the local host (this is important because these GUI tools will try to connect to the local host with a socket, which is not what we want.) Now you can initiate a connection by executing:

$ ssh -f -N remotesql

Finally, activate the MySQL administrator account and, through your trust certificate, connect it to the me.domain.com 13306 port (whether it's a user account or a root account). In order to connect properly, you may have to give user@localhost.localdomain permission.

By doing this, you will be able to use any system on the local web to connect to the remote database without risk across the Internet (unless the firewall rules on the local machine prevent it), and then you can still use the local MySQL command-line tool to manipulate the remote database:

$ 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.