MySQL8.0初始化操作

附海文网盘:https://help.seafile.com/zh/syncing_client/syncing_librarise.html
https://www.jianshu.com/p/5c1198aefe71
skip-grant-tables#直接跳过密码登录
###############################################
default_authentication_plugin=mysql_native_password ##启动之前打开

连接MySQL服务器,修改密码

1.grep 'temporary password' /var/log/mysqld.log
2.set global validate_password.policy=0;
3.set global validate_password.length=6;
4.alter user user() identified by "123456"; //修改登陆密码
5.flush privileges;

###########################################
用户授权和修改密码

创建账号密码

CREATE USER wangwei@127.0.0.1 IDENTIFIED BY 'passowrd';

授予权限

GRANT ALL ON . TO wangwei@127.0.0.1 WITH GRANT OPTION;

删除权限

REVOKE all privileges ON databasename.tablename FROM 'username'@'host';

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
###############################################

MySQL8.0中带过期时间用户的创建:

CREATE USER `wangwei`@`127.0.0.1` IDENTIFIED BY 'wangwei' PASSWORD EXPIRE INTERVAL 90 DAY;
GRANT ALL ON *.* TO `wangwei`@`127.0.0.1` WITH GRANT OPTION;

########################################################################
default_authentication_plugin=mysql_native_password来改变认证加密方式
update mysql.user set plugin='mysql_native_password';
###############################################################

select Host,User,plugin,authentication_string from mysql.user;
update user set authentication_string='' where user='root';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

####################################################################################################
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户密码
FLUSH PRIVILEGES; #刷新权限

##########################################
当plugin的认证方式改变后,之前的对应的plugin的认证密码将会失效。

posted @ 2020-07-18 13:16  笑傲运维  阅读(836)  评论(0编辑  收藏  举报