背景
昨天在做一个小服务时,需要前端同事连接本机 Mysql 进行调试,但是在同一个局域网下连接总是失败,查找资料发现需要将 mysql 授权访问,使用 grant all privileges on * . * to 'user'@'192.168.0.163' identified by '123'; 其中 user 是授权用户名,后面的 IP 是允许连接的 IP,最后面则是登陆密码。在 Mysql 执行这条语句报错:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'test' with grant option' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '

在局域网环境中,为使前端同事能连接到运行在本机的MySQL 8.0.25数据库进行调试,需授权外部访问。由于MySQL 8以上版本的授权方式变化,不能直接使用'%'通配符。解决方案是通过执行特定的MySQL命令来允许特定IP地址的连接。
最低0.47元/天 解锁文章
3183

被折叠的 条评论
为什么被折叠?



