收藏文章 楼主

centos 安装mysql8.0 并修改root密码,解决密码不符合当前策略要求

版块:linux   类型:普通   作者:小绿叶技术博客   查看:638   回复:0   获赞:0   时间:2021-07-28 17:40:02

yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm -y

# yum localinstall是用来安装本地rpm包的命令,首先rpm包要先下载到本地,然后在本地目录执行yum localinstall *.rpm


yum install mysql-community-server -y

# 安装mysql8


grep 'temporary password' /var/log/mysqld.log

# 查看root用户密码root@localhost: #JN3*dNuh=iv; 密码是:#JN3*dNuh=iv


mysql -uroot -p#JN3*dNuh=iv -e" set global validate_password.policy=0 ; set global validate_password.length=6; use mysql;alter user 'root'@'localhost' identified by 'eisc.cn';"

# 解决密码不符合当前策略要求:密码最小长度(6)set global validate_password.policy=0 ; set global validate_password.length=6;

# 进入mysql数据库,更新root再本地的密码为:eisc.cn


user="eisc";database="eisc";passwd="eisc.cn"   ; mysql -uroot -peisc.cn -e "create database $database character set utf8 collate utf8_bin; create user '$user'@'localhost' identified by '$passwd';create user '$user'@'%' identified by '$passwd' ; show databases;SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS ListUsername FROM mysql.user where User='$user';           grant select,create,update,delete on *.* to '$user'@'localhost' ; grant select,create,update,delete  on *.* to '$user'@'%' ; SHOW GRANTS FOR $user;FLUSH PRIVILEGES;"

# 创建数据库,创建远程和本地用户,授权用户,查看权限

# mysql 8 只能先创建用户,再进行授权。 生效(刷新权限)

# 撤销所有授权:revoke privileges on *.* from 'eisc'@'localhost'


user="eisc";database="eisc";passwd="eisc.cn"   ; mysql -uroot -peisc.cn -e "drop database $database; drop user '$user'@'localhost' ;drop user '$user'@'%'; "

# 一键删除:数据库,用户


user="root";database="eisc";passwd="eisc.cn"   ; mysql -uroot -paaaassss -e "use mysql;select user,authentication_string from user; alter user '$user'@'localhost' identified by '$passwd'; alter user '$user'@'%' identified by '$passwd'; " 

# 更新root 用户密码为:eisc.cn 


 mysql -uroot -peisc.cn -e "select now();"

# 使用新密码登录数据库查看时间


# wget www.eisc.cn/file/shell/mysql8-install.sh

提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:centos 安装mysql8.0 并修改root密码,解决密码不符合当前策略要求

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息