文章目录
root处理方法
登陆到mysql命令行:
mysql -u root -p
选择mysql库,用户信息都存在这个库的user表中
use mysql;
select host, user, authentication_string, plugin from user
用户对应的主机是localhost,而不是%,所以不能连接。
授权 root 用户的所有权限并设置远程访问
CREATE USER 'root'@'%' IDENTIFIED BY 'newpassword';
GRANT ALL ON *.* TO 'root'@'%';
刷新权限
flush privileges;
修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword' PASSWORD EXPIRE NEVER;
更新 root 用户密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
刷新权限
如果更新密码时报 The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
,则执行下面语句刷新权限,然后再次执行更新密码操作
flush privileges;
普通用户远程连接权限
给普通用户远程连接的权限:
GRANT ALL ON 指定库.* TO 'myuser'@'%';
更新 该 用户密码
ALTER USER 'myuser'@'%' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
刷新权限
FLUSH PRIVILEGES;
转载于无知的蜗牛:https://blog.csdn.net/weixin_37998647/article/details/80428613