且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

centos7 yum 安装 MySQL

更新时间:2022-09-15 22:39:52

一 查看版本
cat /etc/redhat-release 

 

二 安装yum源

rpm -ivh https://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm

备注:

CentOS 7将MySQL从默认的yum源中移除,用mariadb代替了,所以单独导入安装源 

1 如果上面连接失效,请打开下面连接,按照系统版本替换下载连接
2 默认安装5.7版本,如果要安装5.6版,修改/etc/yum.repos.d/mysql-community.repo
3 将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可

 

三 安装MySQL
yum install mysql-community-server

 

四 服务启动
systemctl start mysqld
systemctl enable mysqld 

 

五 修改root本地登录密码
mysqladmin -u root  -p oldpass password "newpass"
备注:

1 mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码
2 grep 'temporary password' /var/log/mysqld.log 找到root默认密码
3 mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误 













本文转自younger00851CTO博客,原文链接:http://blog.51cto.com/younger008/1905319 ,如需转载请自行联系原作者