MySQL YUM安装教程
一、安装MySQL YUM源
1.1 由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
1.2 RPM安装repo
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
1.3 执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件
mysql-community.repo
mysql-community-source.repo
1.4 查看yum源配置
vim /etc/yum.repos.d/mysql-community.repo
【注】使用yum安装MySQL想要选择具体某个版本的时候,可以将其它版本的yum仓库都屏蔽掉。
二、安装MySQL
2.1 使用yum命令安装
yum install mysql-server -y
systemctl start mysqld # 启动MySQL
#(1)报错问题:如果安装过程报如下错误
Total 42 MB/s | 213 MB 00:00:05
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-9.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Public key for mysql-community-client-5.7.40-1.el7.x86_64.rpm is not installed
Failing package is: mysql-community-client-5.7.40-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
#(2)解决方案:MySQL GPG做过升级,重新获取一下即可
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-server -y
2.2 配置MySQL
grep 'temporary password' /var/log/mysqld.log # 获取安装时的临时密码
倘若没有:
A.删除原来安装过的mysql残留的数据
rm -rf /var/lib/mysql
B.再启动mysql
[root@Star /]# systemctl restart mysqld.service # 启动MySQL
[root@Star /]# systemctl enable mysqld.service # 开机自启
[root@Star /]# mysql -u root -p # 登录
mysql> set password=password("yourpassword"); # 登录成功后修改密码
mysql> flush privileges; # 权限刷新
【注意】mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误。
推荐文章:MySQL安全插件-密码复杂度+密码过期策略+登录失败处理
[root@Star /]# mysql_secure_installation # 设置安全选项
作者:UStarGao
链接:https://www.starcto.com/mysql/62.html
来源:STARCTO
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
UCloud云平台推荐
随便看看
- 2021-05-21第三方常用工具收录
- 2021-01-23MySQL YUM安装教程
- 2021-11-02开源网盘系统nextcloud容器化部署
- 2021-03-18Linux入侵检测AIDE-检查文件的完整性
- 2021-07-20CI/CD Pipeline之Gitlab部署