安装好mysql后,navicat远程连接报错。默认情况下,mysql帐号不允许从远程登陆,只能在localhost登录。需要将root用户的host从localhost更新为%
1 创建 ‘root’@’%’: CREATE USER ‘root’@’%’ IDENTIFIED BY ‘mypassword’;此处报错,需要将 ‘root’@'localhost’的密码设置为空。
2 执行如下操作将密码置空
use mysql;
update user set authentication_string=’ ’ where user=‘root’;
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ’ ';
3.再次执行完成修改:
CREATE USER ‘root’@’%’ IDENTIFIED BY ‘’;
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘’;
FLUSH PRIVILEGES;
将密码设置成原来密码
update user set authentication_string=‘mypassword’ where user=‘root’;
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘mypassword’;
4 此时能连上数据库,但是没有权限进行读写操作。需要授权
grant all privileges on . to root@’%’ with grant option;