root登录进去执行以下命令就可
use mysql;
update user set host = % where user = root;
FLUSH PRIVILEGES;
授权法
在安装mysql的设备上运行mysql的客户端 :MySQL 8.0 Command Line Client
1、mysql> use mysql;
//这般应该能够进入MySQL服务器
2、mysql> ALTER USER root@% IDENTIFIED BY 123456 PASSWORD EXPIRE NEVER;
//% 暗示 赋予任何主机拜访数据的权限,例如,你想 root 运用 password 从任何主机连接到mysql服务器的话,倘若想运用指定的IP来连接mysql的话,只必须把%改成对应的ip就可。
3、mysql> ALTER USER root@% IDENTIFIED with mysql_native_password by 123456;
4、mysql> ALTER USER root@% IDENTIFIED with mysql_native_password by 123456;
5、mysql> flush privileges;
6、mysql>EXIT
退出MySQL服务器,这般就能够在其它任何的主机上以root身份登录
下面是截图:
mysql> use mysql;
Database changed
mysql> ALTER USER root@% IDENTIFIED BY 123456 PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER USER root@% IDENTIFIED with mysql_native_password by 123456;
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
————————————————
版权声明:本文为CSDN博主「LongtengGensSupreme」的原创文案,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/LongtengGensSupreme/article/details/104972406
新手耗时8个小时处理,太难了
|