本机的mysql数据库中有两条user='root'的记录,将其中一条host='localhost'的host修改为'%'后,虽然可以通过远程访问数据库了,但是使用localhost或者127.0.0.1又无法访问数据库了。
经过一番折腾,发现可以通过创建用户的方法来解决这个问题。不需要修改user表中的任何数据,在本地用root登陆mysql后,执行下面的语句,创建用户名为'root',密码为'123456'的用户。执行完以后,查看user表,发现新增了一条host='%',user='root'的记录,并且各项权限与其它'root'一样,再次使用192.168.1.13进行访问,发现可以正常访问了。
grant all privileges on *.* to Root identified by "c#Sys123";
flush privileges;
1
2
3
4
|
grant
all
on
*.*
to
root identified
by
'123456'
with
grant
option
;
|