mysql8.0.32设置root用户可以远程访问
未设置远程访问,会报如下的错
[root@cenots7 ~]# mysql -h192.168.30.20 -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'192.168.30.90' (using password: YES) [root@cenots7 ~]#
开启root用户的远程访问
mysql> set global validate_password.policy=LOW; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password.length=6; Query OK, 0 rows affected (0.00 sec) mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.01 sec) mysql> grant all privileges on *.* to 'root'@'%'; Query OK, 0 rows affected (0.01 sec)
提示意思是不能用grant创建用户,mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,8.0以后已经不支持,所以必须先创建用户,然后再授权,如上述命令
现在就可以了
[root@cenots7 ~]# mysql -h192.168.30.20 -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'192.168.30.90' (using password: YES) [root@cenots7 ~]# mysql -h192.168.30.20 -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2256376 Server version: 8.0.31 MySQL Community Server - GPL Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!