Home  >  Article  >  Database  >  Mysql database sets remote connection permissions

Mysql database sets remote connection permissions

藏色散人
藏色散人forward
2019-02-13 15:55:213363browse

Problem phenomenon

Mysql is installed and the local login is normal. When entering the correct account and password remotely to log in, the error is as follows

Mysql database sets remote connection permissions

Cause of the problem

The remote IP does not have login permission. By default, the root user can only log in on localhost, that is, on this machine. You need to set up to allow other IPs to log in. permissions.

Solution

1. Log in to the database inside the server, and then execute

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

This statement means to the root user You can log in to the database from any IP and operate any object in any database.

Among them:

*.* The first * refers to the database

* represents all databases

The second * refers to the database object

*Represents all objects in the database

'root'@'%' root is the database user to be authorized

% represents the IP allowed to log in

123456 is Your database password

If you want to restrict login to 1.1.1.1, change % to 1.1.1.1. After execution, execute flush privileges; refresh permissions

Mysql database sets remote connection permissions

2. Then the mysql client on the remote computer can be connected.

Mysql database sets remote connection permissions

Mysql database sets remote connection permissions

Related recommendations: "mysql tutorial"http ://m.sbmmt.com/course/list/51.html

The above is the detailed content of Mysql database sets remote connection permissions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:aliyun.com. If there is any infringement, please contact admin@php.cn delete