1.本地登录
mysql -u root -p
Enter password:
2.更新root用户的Host
mysql> use mysql;
mysql> update user set Host='%' where User='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3.远程连接就可以了
root@NSCCDS24:/opt/mysql/docker-compose# mysql -u root -p -h 172.16.20.224
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 88
Server version: 8.0.29 MySQL Community Server - GPL