环境
OS:CentOS7.6
Mysql:Mysql5.7
- 获取更新包
Mysql官网:https://dev.mysql.com/
到http://dev.mysql.com/downloads/repo/yum/ 去下载rpm包更新一下。#下载mysql源安装包 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm #安装mysql源 yum localinstall mysql57-community-release-el7-8.noarch.rpm #检测源是否安装成功 yum repolist enabled | grep "mysql.*-community.*"
- 安装
修改配置yum 安装mysql的版本,这里安装MySQL5.7版本,修改“enabled=1”。
vim /etc/yum.repos.d/mysql-community.repo#Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
yum安装
yum install mysql-community-server
systemctl start mysqld //启动mysql服务
systemctl status mysqld
systemctl enable mysqld
systemctl daemon-reload //重载服务 - 配置
mysql5.7安装时会产生一个默认密码,查看此密码的文件一般存在于/var/log/mysqld.log上。
grep ‘temporary password’ /var/log/mysqld.log
登录mysql
mysql -uroot -p
可看到mysql5.7版本默认登录后要求修改密码,采用了密码机制,默认为medium,要求密码有大写字母及特殊字符。
修改密码:mysql> set password for 'root'@'localhost'=password('xxxxxxxx');
查看密码策略:
mysql> show variables like '%password%'
0 => LOW,1 => MEDIUM,2 => STRONG
命令行修改:
set global validate_password_policy=0; //设置密码策略等级
set global validate_password_length=6; //设置密码最小长度
重启mysql服务
systemctl restart mysqld
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/183547.html