mysql open remote connection (windows)

mysql version: MySQL Server 5.7

1. Open the firewall port

2. Configure the user permissions of the MySQL service

 Open cmd and enter the following command to log in to mysql, then enter the password, and press Enter

mysql -u root -p

Then enter the command

use mysql;

View information about the current root user of the mysql database

select host,user,plugin from user;

host displays localhost (default), indicating that only local access is supported and remote access is not allowed

Change the host default configuration for the root user

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

 

 Check the information again, the host of root has changed

select host,user,plugin from user;

  Refresh permissions, the link is successful

flush privileges;

change Password

alter user 'root'@'%' identified with mysql_native_password by '密码';

Set password to never expire

alter user 'root'@'%' password expire never;

 Refresh permissions

flush privileges;

Reference: https://www.jb51.net/article/253557.htm

Guess you like

Origin blog.csdn.net/qq_41579327/article/details/128583034