MySQL Remote connection setup issues (GO)

Source: Internet
Author: User

If the Web and database are not on the same server, the MySQL server needs to allow remote links for the Web site to function properly.
There are two ways to set up remote links for MySQL:

1. Change the table method.
It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"
Mysql-u root-pvmwaremysql>usemysql;mysql>update User Set host = '% ' where user = ' root '; mysql>select host, user Fromuser;

2. Authorization law.
For example, you want to myuser use MyPassword to connect to a MySQL server from any host.  
GRANT All privileges on * * to ' myuser ' @ '% ' identified by ' mypassword ' with grantoption; If you want to allow the user to connect to the MySQL server myuser from the IP 192.168.1.3 host, and use MyPassword as the password grant all privileges on * * to ' myuser ' @ ' 192.168.1.3 ' Identified by ' MyPassword ' with GRANT option; 


a prompt with "Query OK, 0 rows Affected (0.00 sec)" appears when you are finished running, indicating that the authorization was successful.  authorization is successful and you need to open port 3306. Otherwise, remote still can't access.    The following is also an excerpt from the network ...   Setting up MySQL on Ubuntu can be accessed remotely

1. Does the 3306 port not open?

Use the Nestat command to view the 3306 port status:

~# Netstat-an | grep 3306

TCP 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

From the results, it can be seen that port 3306 is only listening on IP 127.0.0.1, so it denies access to other IPs.

Workaround: Modify the/etc/mysql/my.cnf file. Open the file and find the following:

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

# localhost which are more compatible and are not less secure.

Bind-address = 127.0.0.1

Comment out the above line or replace the 127.0.0.1 with the appropriate IP.

After restarting, re-use netstat detection:

~# Netstat-an | grep 3306

TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

2. Did you solve the problem?

Now test with the following command:

~# mysql-h 10.1.1.2-u root-p

Enter Password:

ERROR 1130 (00000): Host ' b0324-desktop.local ' isn't allowed to connect to this MySQL server

The result is unexpected, or not.

Workaround: It is also necessary to assign user rights to each remote user.

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

Mysql> Grant all on database_name.* to [e-mail protected] '% ' identified by ' User_password ';

where database_name, user_name and User_password are set according to the actual situation.

After the completion of the use of the MySQL command connection, prompt success, in order to ensure that the correct can be remote landing test.

From:http://blog.sina.com.cn/s/blog_6e0c0fdf01017bga.html

MySQL Remote connection setup issues (GO)

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.