How to configure mysql remote access in ubuntu

Source: Internet
Author: User

1. Port 3306 is not enabled?

Run the nestat command to view the status of port 3306:

~ # Netstat-an | grep 3306

Tcp 0 0 127.0.0.1: 3306 0.0.0.0: * LISTEN

The result shows that Port 3306 only listens to the IP address 127.0.0.1, so access from other IP addresses is denied.

1. Change the/etc/mysql/my. cnf file, find bind-address = 127.0.0.1, comment it out, or change it to the ip address that is allowed to access.
2. sudo service mysql restart mysql
3. netstat-an | grep 3306: check the port status. If tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN is displayed, the modification takes effect.
4. Execute the mysql authorization statement:

The code is as follows: Copy code

1 grant all privileges on *. * TO 'user' @ '% 'identified BY 'password' with grant option;

*. * Indicates authorizing all databases, and % indicates the authorized ip address (% indicates that all IP addresses are accessible ). Database_name, user_name, and user_password are set based on the actual situation.


5. The remote connection test is successful.

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.