Home  >  Article  >  Database  >  How to enable remote login permissions for users in MySQL

How to enable remote login permissions for users in MySQL

WBOY
WBOYforward
2023-05-31 14:43:0611748browse

MySQL enables user remote login permissions

After creating a Mysql container in Docker, you need to use tools such as: navicate to connect to the MySQL service in the container, but

prompts Access denied for user 'root'@ 'x.x.x.x' (using password: YES) error. If there is no problem with entering the container using the command to confirm the password, then it may be that there is no development remote permission.

The first step: select the mysql database

use mysql;

The second step: modify the user table in the library, the user user's host=% (any connection)

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

The third step Step: Reload the permission table

flush privileges;

Step 4: Grant remote connection permissions to the root user

grant all privileges on *.* to 'root'@'%' with grant option;
# 赋予权限并修改密码
alter user 'root'@'%' identified with mysql_native_password by '123456';

Open remote access permissions for MySQL

1. Use mysql -u root -p Connect to the local MySQL service

2. After logging in, use use mysql;

3. Use grant all privileges on . to ‘root’@‘%’ identified by ‘ 123456’ with grant option; Grant remote login user permissions (use root account and password 123456, connect to mysql server from any host), refresh permissions FLUSH PRIVILEGES;

4. Use select user,host from user to view the system User

5. Use vim /etc/mysql/mysql.conf.d/mysqld.cnf to modify the access URL of bind-address, and change bind-address=127.0.0.1 to bind-address=0.0.0.0

6. Open port 3306 (this is the default port of MySQL)

The above is the detailed content of How to enable remote login permissions for users in MySQL. For more information, please follow other related articles on the PHP Chinese website!

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