MySql8有新的安全要求,不能像之前的版本那样一次性创建用户并授权,需要先创建用户再进行授权操作。
1、创建新用户
create user 'username'@'host' identified by 'password';
其中username为自定义的用户名;host为登录域名,host为'%'时表示为 任意IP,为localhost时表示本机,或者填写指定的IP地址;paasword为密码
2、为用户授权
grant all privileges on *.* to 'username'@'%' with grant option;
其中*.*第一个*表示所有数据库,第二个*表示所有数据表,如果不想授权全部那就把对应的*写成相应数据库或者数据表;username为指定的用户;%为该用户登录的域名
3、授权后刷新权限
flush privileges;
4、撤销授权
#收回权限(不包含赋权权限)
REVOKE ALL PRIVILEGES ON *.* FROM user_name;
REVOKE ALL PRIVILEGES ON user_name.* FROM user_name;
#收回赋权权限
REVOKE GRANT OPTION ON *.* FROM user_name;
#操作完后重新刷新权限
flush privileges;
© 版权声明
THE END






![The server selected protocol version TLS10 is not accepted by client preferences [TLS12]-深吸氧](https://xiyang-blog.oss-cn-hangzhou.aliyuncs.com/blog/2022/02/20220224201351.png)





暂无评论内容