前言
使用IP地址连接数据库时出错
一、登陆mysql数据库,修改表
use mysql;
update user set host='%' where user='root';
select host,user from user;
flush privileges;
注意:最后一句很重要,目的是使修改生效,如果没有写,则还是不能进行远程连接。
二、授权用户,允许从任何主机连
-- 接到mysql数据库
grant all privileges on *.* to 'root'@'%' identified by 'pwd' with grant option;
flush privileges;
-- 如果只是允许用户从ip为192.168.1.104的主机连接到mysql服务器
grant all privileges on *.* to 'root'@'%192.168.1.104' identified by 'Fmty_888_!@#' with grant option;
flush privileges;
本文介绍了如何解决使用IP地址连接MySQL数据库时遇到的问题。首先,登录MySQL并修改`users`表,将`root`用户的`host`设置为`%`。接着,通过授权命令允许用户从任何主机或特定IP远程连接,如`'root'@'%'`或`'root'@'192.168.1.104'`,并确保使用`flush privileges`使更改生效。
1万+

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



