MySQL Open remote connection

Source: Internet
Author: User
Tags flush

Host ' xxx ' is not a allowed to connect to this MySQL server.

              MySQL Open remote connection

Today in the server installed MySQL, ready to use Mysqlguitools remote login error, prompt: Host ' xxx ' is not allowed to connect to this MySQL server. Found some information on the Internet, is MySQL does not open MySQL remote access rights caused.

Document the solution for future reference. :

1. Log in to Mysql:mysql-uroot-ppwd

2. View the user table:

mysql> use MySQL
Database changed
mysql> Select Host,user,password from user;
+------+------+-------------------------------------------+
| host | user | password |
+------+------+-------------------------------------------+
| localhost | root | *826960fa9cc8a87953b3156951f3634a80bf9853 |
+------+------+-------------------------------------------+
1 row in Set (0.00 sec)

The host and User fields in the table identify the hosts and users who can access the database. For example, the above data means that the local host can only be accessed by the root user. So it's no wonder that remote connections are not connected.

To enable the database to support remote host access, there are two ways to turn on remote access functionality.

The first (change the table method):

Modify the value of the host field to change localhost to an IP address that requires a remote connection to the database. or directly modified to%. Modification to% means that all hosts can access the database through the root user. For convenience, I directly modified into%. Command:mysql> Update user set host = '% ' where user = ' root ';

View the user table again

| Host | user | password |
|% | root | * 826960fa9cc8a87953b3156951f3634a80bf9853 |
1 row in Set (0.00 SEC)

The modification succeeds, the input command mysql> FLUSH privileges; Enter to make the previous modification effective, and then connect the database remotely successfully.

The second type (Authorization law):

For example, if you want root to connect to a MySQL server from any host using MyPassword.
GRANT all privileges on * * to ' root ' @ '% ' identified by ' MyPassword ' with GRANT OPTION;


If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.3 and use MyPassword as the password
GRANT all privileges on * * to ' root ' @ ' 192.168.1.3 ' identified by
' MyPassword ' with GRANT OPTION;

Enter the command mysql> FLUSH privileges; Enter to make the previous modification effective, and then connect the database remotely successfully. Bingo.

Don't forget the final flush privileges; Refreshes the previous modification.


MySQL Open remote 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.