在实际开中,会遇到Navicat不能连接数据库的问题,如图所示:
解决办法:
#先登陆mysql
mysql -u root -p ${your password}
use mysql;
select host, user, authentication_string, plugin from user;
#如果没有host=%的,说明没有启用远程登陆的账户
update user set host='%' where user='root';
#给远程账户授权
Grant all privileges on root.* to 'root'@'%';
#设置密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '${your password}';
#刷新权限
flush privileges;
exit;
#另:mysql7.0版本修改密码语句
update user set password = password('seal123456') where user = 'root';