Host 'XXX' is not allowed to connect to this MySQL server Solution/How to open MySQL remote account

How to open MySQL remote account-1) First log in to MySQL as root account

On the Windows host, click the start menu, run, enter "cmd", enter the console, then cd into the MySQL bin directory, and enter the following command.
        >  MySQL -uroot -p123456                  (123456 is the password of the root user.)

 

How to open a MySQL remote account-2) Create a remote login user and authorize
        > 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 privileges to the specified user. It can also be replaced by granting a specific privilege, such as select, insert, update, delete, create, drop, etc. The specific privileges 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.

 

How to open a MySQL remote account-3) After executing the above statement, execute the following statement to take effect immediately.
        > flush privileges; 

Guess you like

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