CentOS 7 无网络下安装MySql 5.7.17

前言:
最近项目需要搭建集群,处于数据安全性的考虑不能连接外网。这样的前提下,需要在CentOS 7 系统的测试服务器上安装 MySQL 5.7.17。手动安装比yum安装麻烦很多。所以在这里写文章记录安装过程,以便于后边再碰到类似问题。

1.mysql下载
mysql下载路径:https://dev.mysql.com/downloads/mysql/
在这里插入图片描述
根据自己的linux版本选择对应的安装包
在这里插入图片描述
几分钟就下载了。
以下是下载好的文件
mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
在这里插入图片描述
2.准备依赖包
依赖包下载网页:
https://centos.pkgs.org/7/centos-x86_64/
在这里插入图片描述
红框处直接搜索需要的依赖包
我这里缺的依赖包有:libaio、m4、net-tools
m4依赖包为例:

  1. 搜索 m4 ——> 下图红框处(尽量选后缀无noarch依赖)
    在这里插入图片描述
  2. 将红框处地址拷贝,并在浏览器打开
    在这里插入图片描述
    下载好的依赖包有以下:
    libaio-0.3.109-13.el7.x86_64.rpm
    m4-1.4.16-10.el7.x86_64.rpm
    net-tools-2.0-0.25.20131004git.el7.x86_64.rpm

3. 依赖包的安装
将依赖包上传到服务器,依次进行安装

[root@imax rh]# rpm -ivh m4-1.4.16-10.el7.x86_64.rpm
warning: m4-1.4.16-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:m4-1.4.16-10.el7                 ################################# [100%]
   
[root@imax rh]# rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm
Preparing...                          ################################# [100%]
    package libaio-0.3.109-13.el7.x86_64 is already installed

[root@imax rh]# rpm -ivh net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
warning: net-tools-2.0-0.25.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOK                                                           EY
Preparing...                          ################################# [100%]
        package net-tools-2.0-0.25.20131004git.el7.x86_64 is already installed

4. 卸载自带的Mysql-libs

[root@imax rh]# rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps

5. mysql安装包的安装

[root@imax rh]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.17-1.e################################# [100%]
   
[root@imax rh]# rpm -ivh mysql-community-libs-*
warning: mysql-community-libs-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.17-1.el7################################# [ 50%]
   2:mysql-community-libs-compat-5.7.1################################# [100%]
   
[root@imax rh]# rpm -ivh mysql-community-devel-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-devel-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-devel-5.7.17-1.el################################# [100%]
        
[root@imax rh]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.17-1.e################################# [100%]
   
[root@imax rh]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.17-1.e################################# [100%]

[root@imax rh]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
        package mysql-community-client-5.7.17-1.el7.x86_64 is already installed
        
[root@imax rh]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
        package mysql-community-common-5.7.17-1.el7.x86_64 is already installed
        
[root@imax rh]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
        package mysql-community-client-5.7.17-1.el7.x86_64 is already installed
        
[root@imax rh]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKE                                                           Y
Preparing...                          ################################# [100%]
        package mysql-community-server-5.7.17-1.el7.x86_64 is already installed

6. 启动mysql并修改端口号密码
1启动mysql

[root@imax rh]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
[root@imax rh]# service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-11-04 13:56:37 CST; 24s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 4644 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 4571 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 4647 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─4647 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
 
Nov 04 13:56:07 linuxidc systemd[1]: Starting MySQL Server...
Nov 04 13:56:37 linuxidc systemd[1]: Started MySQL Server.

2 重设mysql密码

查看默认密码

[root@imax rh]# cat /var/log/mysqld.log | grep password
2017-11-04T05:56:08.454323Z 1 [Note] A temporary password is generated for root@localhost: ps1DY?%T.Vc4

登录mysql

[root@linuxidc ~]# mysql -u root -p'ps1DY?%T.Vc4'
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

密码重设
设置复杂密码(由于MySQL密码策略,此密码必须足够复杂)

mysql> set password=password("Qs23=zs32");

更改MySQL密码策略

mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;

更改密码策略后便可以更改更容易记的密码了

mysql> set password=password("123456");

3 端口号更改

查看当前端口号

mysql>show global variables like 'port';

3.修改端口:编辑/etc/my.cnf文件

[root@imax rh]#  vi /etc/my.cnf

在 [mysqld] 后加一行

port=3308

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一马什么梅一

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值