标签:man res lib ora off arch variables 服务启动 bsp
安装环境:CentOS7 64位 MINI版,安装MySQL5.7
在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/
# 下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
看到上图所示表示安装成功。
yum install mysql-community-server
systemctl start mysqld
查看MySQL的启动状态
systemctl status mysqld
systemctl enable mysqld
systemctl daemon-reload
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep ‘temporary password‘ /var/log/mysqld.log
mysql -u root -p
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘MyNewPass4!‘;
或者
set password for ‘root‘@‘localhost‘=password(‘MyNewPass4!‘);
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,如下图所示:
通过msyql环境变量可以查看密码策略的相关信息:
show variables like ‘%password%‘;
官网密码策略详细说明:
http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policyMySQL
在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略
# 选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件
validate_password_policy=0
如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:
validate_password = off
重新启动mysql服务使配置生效:
systemctl restart mysqld
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
如果忘记root密码,则按如下操作恢复:
在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi。
mysql -u root
update mysql.user set authentication_string=password(‘123qwe‘) where user=‘root‘ and Host = ‘localhost‘; flush privileges
CentOS7.5 yum 安装与配置MySQL5.7.24
标签:man res lib ora off arch variables 服务启动 bsp
原文地址:https://www.cnblogs.com/huiyi0521/p/10113280.html