Centos7 下离线rpm包安装mysql5.7

1、安装前先要清理在系统是否有MySQL的遗留

    rpm -qa | grep mysql

如果有就使用rpm -e --nodeps mysql以及rm /etc/my.cnf

2、首先下载安装包

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

3、把文件上传到Linux上后解压(tar -xvf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar)

4、依次对如下几个安装包进行安装

        rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm

        rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm

        rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm

        rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm

        rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm

5、在安装mysql-community-server-5.7.20-1.el7.x86_64.rpm前需要安装libaio-0.3.107-10.el6.x86_64.rpm

    下载地址: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(若在有网情况下可执行yum install libaio)

6、查看MySQL的端口是否有被占用:netstat -ln | grep 3306


Centos7 下离线rpm包安装mysql5.7_第1张图片

7、vim /etc/my.cnf

8、重启mysql服务 systemctl restart mysqld.service

9、获取初始密码

    cat /var/log/mysqld.log | grep password


10、将初始密码复制下来,输入如下命令登陆mysql :

mysql -uroot -p

将复制的密码粘贴到命令行中,进入了mysql,使用如下命令修改密码:

set password=password('新密码');

flush privileges;

添加远程访问权限:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; 

flush privileges;

重启mysql服务即可使用。

更加详细文章请看:https://blog.csdn.net/weixin_42266606/article/details/80879571

你可能感兴趣的:(Centos7 下离线rpm包安装mysql5.7)