1.由于CentOS 的yum源中没有MysqL,需要到MysqL的官网下载yum repo配置文件。
wget http://dev.MysqL.com/get/MysqL57-community-release-el7-9.noarch.rpm
2.安装yum repo文件
rpm -ivh MysqL57-community-release-el7-9.noarch.rpm
执行完成后会在/etc/yum.repos.d/
目录下生成两个repo文件MysqL-community.repo
MysqL-community-source.repo
3.然后更新yum缓存
yum clean all yum makecache
4.安装MysqL
yum install MysqL-community-client.x86_64 MysqL-community-common.x86_64 MysqL-community-devel.x86_64 MysqL-community-libs.x86_64 MysqL-community-server.x86_64
或者
rpm install MysqL-server
5.启动MysqL
service MysqLd start
6.查看初始密码
grep 'temporary password' /var/log/MysqLd.log
得到如下内容:
2016-10-28T10:36:32.369073Z 1 [Note] A temporary password is generated for root@localhost: 5Oazqgpiat!p
7.使用初始密码登录
MysqL -u root -p //回车,然后输入上一步查到的初始密码
8.更改初始密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; //现在的MysqL对密码强度要求较高,需要包含大小写字母、数字和特殊字符
至此,MysqL-server安装完成
原文链接:https://www.f2er.com/centos/380085.html