本文为参考CentOS 7 RPM 安装 MySQL5.7自己尝试在CentOS上安装MySQL5.7,记录下来,方便自己以后查阅

1:环境

操作系统:CentOS Linux release 7.2.1511
MySQL版本:mysql-5.7.17-1

2:下载RPM安装包

前往MySQL官网下载RPM安装包,本文使用的版本是mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar

temp.gif

下载完成之后,将安装包上传至服务器,然后解压tar xvf mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar

截图20161222112545.png

3:安装

依次执行如下命令安装
rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
执行前三个命令顺利成功,但是,执行第四个命令时,报错
a:缺少perl,执行yum install perl命令安装,大致错误如下
error: Failed dependencies:
/usr/bin/perl is needed by mysql-community-server-5.7.17-1.el7.x86_64.rpm
b:缺少libaio,前往http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm下载,执行rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm命令安装,大致错误如下
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.17-1.el7.x86_64.rpm
然后,再次执行上述第四个命令,成功

4:数据库初始化

执行mysqld –initialize –user=mysql命令初始化,初始化完成后,会生成一个root账号密码,位于/var/log目录下的mysqld.log文件最后一行
现在,使用上述密码启动数据库
systemctl start mysqld
mysql -uroot -p

5:修改密码

alter user ‘root’@’localhost’ identified by ‘new_password’

6:添加远程用户

使用如下sql添加远程用户
grant all privileges on *.* to ‘account’@’%’ identified by ‘password’ with grant option

文章来源于互联网,如有雷同请联系站长删除:CentOS7 RPM 安装 MySQL5.7

发表评论