Enable MySQL remote access in Linux

Source: Internet
Author: User

(1) Check whether MySQL 3306 is open to the outside world. By default, MySQL does not provide the external access function. The method is as follows:

1 ~ # Netstat-an | grep 3306

2 tcp 0 0 127.0.0.1: 3306 0.0.0.0: * LISTEN

It can be seen from the above that port 3306 of mysql only listens to local connections, which hinders access from the external IP address to the database. The modification method is actually very simple, enter the directory of the mysql configuration file (/etc/mysql/my. cnf), find the following content in the file:


1 # Instead of skip-networking the default is now to listen only on

2 # localhost which is more compatible and is not less secure.

3 bind-address = 127.0.0.1

Add a comment to bind-address (or change it to the IP address of the client host you want to use) (this is not successful ).
In this way, even if the mysql remote access port is enabled, another more important step is to authorize the remote user.

(2) check whether the client user has access permissions.
To grant the user access permission to the mysql client, we can authorize the user as follows:

1 mysql> grant all on *. * to user_name @ '%' identified by 'user _ password ';

2 # Or

3 mysql> grant all privileges on *. * to username @ "%" identified by "password"; # (this sentence is accurate)

4 # Or

5 create user 'test' @ '125.76.229.113 'identified by '123 ';

6 create user 'test' @ '125.76.229.215 'identified by '123 ';

7 create user 'test' @ '60.195.252.106 'identified by '123 ';

The user permissions granted by the preceding command can access any database and table in mysql ).
After completing the above two steps, restart mysql to remotely log on to the mysql server. The Mysql restart command is as follows:

View the source code print help 1 sudo/etc/init. d/mysql restart

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.