HOSt ip is not allowed to connect to this MySql server

Solution:

1. Change the table method.

It may be that your account is not allowed to log in from the remote, only on localhost. At this time, as long as you are on the localhost computer, after logging in to mysql, change the "host" item in the "user" table in the "mysql" database, from "localhost" to "%"

mysql -u root -pvmwaremysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>flush privileges;

mysql>select host, user from user;

mysql>quit

2. Authorization method.

For example, if you want myuser to connect to the mysql server from any host using mypassword.

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

If you want to allow user myuser to connect to mysql server from host with ip 192.168.1.6 and use mypassword as PasswordGRANT

ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3'



If you want to allow user myuser to connect to dk database of mysql server from host with ip 192.168.1.6 and use mypassword as password

GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

The first method I used, I found that it didn't work at first, I checked it on the Internet, and executed one less statement mysql>FLUSH RIVILEGES to make the modification take effect. That's it.

Another method, but I didn't try it myself I found it on csdn.net, you can take a look.

Run it on the machine where mysql is installed:

1. d:\mysql\bin\>mysql -h localhost -u root //This should be able to enter the MySQL server

2. mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //Grant any host permission to access data

3, mysql>FLUSH PRIVILEGES //Modification takes effect

4, mysql>EXIT //Exit MySQL

server- -------------------------------------------------- ------------------

grant all PRIVILEGES on test_db.* to root@'192.168.1.101'  identified by '123456';


The above statement indicates that all permissions of the test_db database are authorized to the root user, allowing the root user to log in remotely at the IP 192.168.1.101, and setting the root user's password to 123456.

Let’s analyze all the parameters one by one:

all PRIVILEGES means to grant all permissions to the specified user, here can also be replaced with a specific permission, such as select, insert, update, delete, create, drop, etc., use “, " are separated by commas.

test_db.* indicates which table the above permissions are for, test_db refers to the database, and the following * indicates that for all tables, it can be deduced that: for all tables in all databases, the authorization is "*.*", for All tables in a database are authorized as "database name.*", and a table in a certain database is authorized as "database name.table name".

root indicates which user you want to authorize. This user can be an existing user or a non-existing user.

192.168.1.101 indicates the IP address that allows remote connection. If you want to not restrict the IP of the link, you can set it as "%".

123456 is the user's password.



After executing the above statement, execute the following statement to take effect immediately.
        > flush privileges;


mysql5.7 modify the password of the root user and
use mysql to connect to the server
to change the password: update mysql.user set authentication_string=password('root') where user='root';
*It is important to note that there is no Password field in the user table under the new version of the mysql database.

Instead , the encrypted user password is stored in the authentication_string field


. mysql> flush privileges;
mysql> quit;

from: http://joinyo .iteye.com/blog/1489380
  http://www.cnblogs.com/zhangzhu/p/3274831.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326917357&siteId=291194637