Set MySQL remote access on Ubuntu

Source: Internet
Author: User

Today, I used myeclipse's dB explorer to connect to MySQL installed on ubuntu8.04. An error is always prompted, but access to Ubuntu is normal. So I started to find the cause:

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.

Solution: Modify the/etc/MySQL/My. CNF file. Open the file and find the following content:

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

# Localhost which is more compatible and is not less secure.

Bind-address = 127.0.0.1

Comment out the above line or replace 127.0.0.1 with a suitable IP address. We recommend that you comment out this line.

After restarting, use netstat again for detection:

~ #
Netstat-an | grep 3306

TCP 0 0 0.0.0.0: 3306 0.0.0.0: * listen

2.
Is the problem solved?

Run the following command to test the function:

~ #
Mysql-H 10.1.1.2-u root-P

Enter password:

Error 1130 (00000): Host 'b0324-desktop. local' is not allowed to connect to this MySQL Server

The results are unexpected.

Solution: users must be assigned permissions to remote users.

Log on to the MySQL server and use the grant command to assign permissions.

Mysql> grant all on database_name. * To user_name @ '%' identified
By 'user _ password ';

Database_name, user_name, and user_password are set based on the actual situation.

After the connection is complete, use the MySQL command to connect and prompt that the connection is successful. In order to ensure the correctness, You can remotely log on and test the connection.

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.