linux 无外网情况下安装 mysql

由于工作需要,需要在一台装有 CentOS 系统的测试服务器上安装 MySQL ,由于该服务器上存有其他比较重要的测试数据,所以不能连接外网。由于之前安装 MySQL 一直都是使用 yum 命令一键搞定的,所以手动安装的话还是有些麻烦的。所以在这里我将我在安装过程中遇到的一些问题记录下来。

1.需求就不用讲了,客户现场,政府环境,银行环境,大多是没网的,所以无网安装是很有必要的

mysql下载路径:https://dev.mysql.com/downloads/mysql/

查看自己Linux系统版本

[[email protected] ~]# cat /etc/RedHat-release

CentOS Linux release 7.3.1611 (Core)

往下拉继续选择

选择对应的下载,mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

这样几分钟就下载了。

2.准备依赖包:

a.numactl 软件包:

  • numactl-2.0.9-6.el7_2.x86_64.rpm
  • numactl-devel-2.0.9-6.el7_2.x86_64.rpm
  • numactl-libs-2.0.9-6.el7_2.x86_64.rpm

b.其他相关支持:

  • perl-Data-Dumper-2.145-3.el7.x86_64.rpm
  • libaio-0.3.109-13.el7.x86_64.rpm

下载方式:https://pkgs.org

下面是下载路径:

libaio-0.3.109-13.el7.x86_64.rpm

perl-Data-Dumper-2.145-3.el7.x86_64.rpm

numactl-libs-2.0.9-6.el7_2.x86_64.rpm

numactl-devel-2.0.9-6.el7_2.x86_64.rpm

numactl-2.0.9-6.el7_2.x86_64.rpm

3.上传文件到服务器上

localhost:Downloads kylin$ scp -r numactl-2.0.9-6.el7_2.x86_64.rpm [email protected]:/root/

[email protected]‘s password:

numactl-2.0.9-6.el7_2.x86_64.rpm              100%  65KB  2.1MB/s  00:00   

localhost:Downloads kylin$ scp -r numactl-libs-2.0.9-6.el7_2.x86_64.rpm [email protected]:/root/

[email protected]‘s password:

numactl-libs-2.0.9-6.el7_2.x86_64.rpm        100%  29KB  1.7MB/s  00:00   

localhost:Downloads kylin$ scp -r numactl-devel-2.0.9-6.el7_2.x86_64.rpm [email protected]:/root/

[email protected]‘s password:

numactl-devel-2.0.9-6.el7_2.x86_64.rpm        100%  23KB  1.5MB/s  00:00   

localhost:Downloads kylin$ scp -r perl-Data-Dumper-2.145-3.el7.x86_64.rpm [email protected]:/root/

[email protected]‘s password:

perl-Data-Dumper-2.145-3.el7.x86_64.rpm      100%  47KB  1.2MB/s  00:00   

localhost:Downloads kylin$ scp -r libaio-0.3.109-13.el7.x86_64.rpm [email protected]:/root/

[email protected]‘s password:

Permission denied, please try again.

[email protected]‘s password:

libaio-0.3.109-13.el7.x86_64.rpm              100%  24KB 618.3KB/s  00:00   

localhost:Downloads kylin$ scp -r mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar [email protected]:/root/

[email protected]‘s password:

mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar                    100%  566MB  4.5MB/s  02:05

查看上传的包

[[email protected] ~]# ls

anaconda-ks.cfg                          numactl-devel-2.0.9-6.el7_2.x86_64.rpm

libaio-0.3.109-13.el7.x86_64.rpm          numactl-libs-2.0.9-6.el7_2.x86_64.rpm

miniconda2                                perl-Data-Dumper-2.145-3.el7.x86_64.rpm

mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar  pythonshell

numactl-2.0.9-6.el7_2.x86_64.rpm

4.安装

第一步,先安装依赖,安装 perl-Data-Dumper-2.145-3.el7.x86_64.rpm 和 libaio-0.3.109-13.el7.x86_64.rpm

[[email protected] ~]# 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

[[email protected] ~]# rpm -ivh perl-Data-Dumper-2.145-3.el7.x86_64.rpm

Preparing...                          ################################# [100%]

Updating / installing...

   1:perl-Data-Dumper-2.145-3.el7    ################################# [100%]

第二步,继续安装 numactl相关

[[email protected] ~]# rpm -ivh numactl*

Preparing...                          ################################# [100%]

    package numactl-libs-2.0.9-6.el7_2.x86_64 is already installed

如果不安装这个包会报错,错误如下(本人未测试):

error: Failed dependencies:

 

libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.18-1.el7.x86_64

 

libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.18-1.el7.x86_64

 

libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.18-1.el7.x86_64 

若此时直接安装mysql,还会异常:

warning: mysql-community-libs-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: Failed dependencies:

 mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.18-1.el7.x86_64

 mariadb-libs is obsoleted by mysql-community-libs-5.7.18-1.el7.x86_64

第一行还能看明白,是依赖问题,第二行的“mariadb-libs 被废弃”是什么鬼?废弃了为什么不提供一个新的还要出现这种弱智提示呢?经过一番搜寻,才发现是因为在CentOS 7上已经有一个mariadb 而这个会与 MySQL的mariadb发生冲突。所以此时我们需要将系统自带的mariadb卸载掉,然后使用mysql自带的mariadb。

接下来查看mariadb版本

[[email protected] ~]# rpm -qa | grep mariadb

mariadb-libs-5.5.52-1.el7.x86_64

卸载系统安装的mariadb

[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

[[email protected] ~]# rpm -qa | grep mariadb

[[email protected] ~]#

解决好这个问题后,就可以安装mysql了,先解压mysql,并查看安装包

[[email protected] ~]# tar -xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

[[email protected] ~]# ls

anaconda-ks.cfg

libaio-0.3.109-13.el7.x86_64.rpm

miniconda2

mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

mysql-community-client-5.7.20-1.el7.x86_64.rpm

mysql-community-common-5.7.20-1.el7.x86_64.rpm

mysql-community-devel-5.7.20-1.el7.x86_64.rpm

mysql-community-embedded-5.7.20-1.el7.x86_64.rpm

mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm

mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm

mysql-community-libs-5.7.20-1.el7.x86_64.rpm

mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm

mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm

mysql-community-server-5.7.20-1.el7.x86_64.rpm

mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm

mysql-community-test-5.7.20-1.el7.x86_64.rpm

numactl-2.0.9-6.el7_2.x86_64.rpm

numactl-devel-2.0.9-6.el7_2.x86_64.rpm

numactl-libs-2.0.9-6.el7_2.x86_64.rpm

perl-Data-Dumper-2.145-3.el7.x86_64.rpm

pythonshell

直接安装,报错:

[[email protected] ~]# rpm -ivh mysql-community-*

warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

    net-tools is needed by mysql-community-server-5.7.20-1.el7.x86_64

    perl(JSON) is needed by mysql-community-test-5.7.20-1.el7.x86_64

貌似不能直接全安装,有顺序,继续:

[[email protected] ~]# rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm

warning: mysql-community-common-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-common-5.7.20-1.e################################# [100%]

[[email protected] ~]# rpm -ivh mysql-community-libs-*

warning: mysql-community-libs-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-libs-5.7.20-1.el7################################# [ 50%]

   2:mysql-community-libs-compat-5.7.2################################# [100%]

[[email protected] ~]# rpm -ivh mysql-community-devel-5.7.20-1.el7.x86_64.rpm

warning: mysql-community-devel-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-devel-5.7.20-1.el################################# [100%]

[[email protected] ~]#

[[email protected] ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

    mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.20-1.el7.x86_64

    net-tools is needed by mysql-community-server-5.7.20-1.el7.x86_64

说缺少net-tools ,下载下来装呗,继续:

net-tools-2.0-0.22.20131004git.el7.x86_64.rpm

[[email protected] ~]# rpm -ivh net-tools-2.0-0.22.20131004git.el7.x86_64.rpm

Preparing...                          ################################# [100%]

Updating / installing...

   1:net-tools-2.0-0.22.20131004git.el################################# [100%]

[[email protected] ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

    mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.20-1.el7.x86_64

[[email protected] ~]# rpm -ivh mysql-community-c

mysql-community-client-5.7.20-1.el7.x86_64.rpm  mysql-community-common-5.7.20-1.el7.x86_64.rpm

[[email protected] ~]# rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm

warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-client-5.7.20-1.e################################# [100%]

[[email protected] ~]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-server-5.7.20-1.e################################# [100%]

中间安装server时,又说必须安装client,至此,mysql安装成功,打完收工。

5.启动查看配置

[[email protected] ~]# service mysqld start

Redirecting to /bin/systemctl start  mysqld.service

[[email protected] ~]# 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.

至此,无网安装难的历史已经结束,至少的我实验没问题了,好像还缺点是什么,数据库密码是啥?

[[email protected] ~]# cat /var/log/mysqld.log | grep password

2017-11-04T05:56:08.454323Z 1 [Note] A temporary password is generated for [email protected]: ps1DY?%T.Vc4

这样就可以登录数据库了,try一下:

[[email protected] ~]# mysql -u root

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

报错了,连输入密码的机会也没有。

[[email protected] ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.7.20

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

登陆成功试试,数据库好使不

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

不改密码,用不了,继续:

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘你的密码‘;

Query OK, 0 rows affected (0.02 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.01 sec)

然后再使用SQL就没问题了

mysql> show databases;

+--------------------+

| Database          |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

用数据库工具链接,出现问题:

不允许远程访问,改继续:

mysql>  GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘你的密码‘ WITH GRANT OPTION;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

再试就没有问题了,至此数据库安装问题基本没有。

查看mysql配置文件地址:

[[email protected] ~]# find / -iname ‘*.cnf‘ -print

/etc/pki/tls/openssl.cnf

/etc/my.cnf

/root/miniconda2/pkgs/openssl-1.0.2l-0/ssl/openssl.cnf

/root/miniconda2/ssl/openssl.cnf

/var/lib/mysql/auto.cnf

查看字符集:

mysql> show variables like ‘char%‘;

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client    | utf8                      |

| character_set_connection | utf8                      |

| character_set_database  | latin1                    |

| character_set_filesystem | binary                    |

| character_set_results    | utf8                      |

| character_set_server    | latin1                    |

| character_set_system    | utf8                      |

| character_sets_dir      | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.01 sec)

至此数据库安装完毕。

原文地址:https://www.cnblogs.com/yhoralce/p/8325142.html

时间: 2024-10-02 05:57:12

linux 无外网情况下安装 mysql的相关文章

无外网情况下RPM方式安装MySQL5.6

RPM方式安装MySQL5.6 a. 检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称) 1 [[email protected] ~]# rpm -qa | grep -i mysql 2 mysql-libs-5.1.66-2.el6_3.x86_64 3 [[email protected] ~]# yum -y remove mysql-libs* b. 下载Linux对应的RPM包,如:CentOS6.4_64对应的RPM包,如下:这里给出我下载好的包,官

CentsOS7无网情况下安装mysql5.7

1.需求就不用讲了,客户现场,政府环境,银行环境,大多是没网的,所以无网安装是很有必要的 mysql下载路径:https://dev.mysql.com/downloads/mysql/ 查看自己Linux系统版本 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) 往下拉继续选择 选择对应的下载,mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar 这

无外网环境下ES5.x安装sql插件

说明: 1.服务器默认不能访问外网,所以网上安装sql插件的方法都不能满足 2.当前ES版本5.6.3 3.sql插件下载地址:https://github.com/NLPchina/elasticsearch-sql 1.下载ES 5.6.3对应的sql插件: 由于服务器不能访问外网,所以只能通过浏览器下载,然后上传到服务器,将插件上传到ES的plugins插件目录 附件是对应插件文件 2.安装sql插件: [[email protected] plugins]# pwd /home/tool

linux最新版本Centos7,断网情况下安装应用程序(必备技能,一学就会)

一.上一章我们了解到可以直接再yum仓库当中安装程序,但是需要网络,而且不用解决依赖关系.这一章教你们如何在断网下安装程序1.我们先把网给断了(演示在没网的情况下,在VM虚拟机实现的)2.设置我们的网卡3.重启网络服务,并且查看我们刚才设置的地址4.清除我们之前yum list的缓存5.使用Centos7镜像,然后去连接6.把镜像挂载7.查看我们的软件包在哪儿?8.配置我们自己的yum仓库 9.查看我们的yum仓库软件包有没有10.输入安装httpd服务的命令11.我们试一试能不能使用访问这个网

非[无]root权限 服务器 下安装perl以及perl模块--转载

转载自http://www.zilhua.com 在本博客中,所有的软件安装都在服务器上,且无root权限.理论上适合所有的用户. 我的安装目录 cd /home/zilhua/software 1.在官方网站下载新版本的源码包: http://www.perl.org/get.html,版本自己选择,我下载的是perl-5.18.0.tar.gz 2.解压 tar zxvf perl-5.18.0.tar.gz 3.进入解压目录 cd /home/zilhua/software/perl-5.

Ubuntu下安装MySql并在外网连接

纯新手教程. 1.安装mysql apt-get install mysql-server mysql-client libmysqlclient15-dev 安装过程中会提示为数据库root账户设置密码,输入两边密码即可 2.进入 mysql mysql -uroot -p 3.重新设置mysql用户root的密码 GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY "123456"; 4.创建新数据库 pro

linux系统下安装mysql数据库(mysql-5.7)

前言: 本文主要介绍如何在linux系统下安装mysql数据库及安装时遇到各种问题该如何解决:     本次安装使用的linux系统是centos,数据库版本是mysql-5.7. 一.安装前准备 root用户登录只linux服务器,在根目录下新建数据库安装目录  /software/mysql:数据库文件数据位置:/data/mysql(可以根据自己的习惯创建) 然后从oracle官网上下载mysql安装包:可以在自己电脑上先下载再上传到linux服务上,如果linux服务器可以访问外网,也可

[Linux基础环境/软件]Linux下安装mysql

我是使用免安装的包mysql-5.5.28-linux2.6-x86_64.tar.gz(在http://dev.mysql.com/downloads/可以下载到最新的包)的.直接解压,然后配置,初始化数据库,启动即可. 安装步骤有: 解压和建立软链: 配置文件和配置参数: 初始化数据库: 启动和关闭: 建立数据库用户和授权. 1. 解压和建立软链: #tar xzvf mysql-5.5.28-linux2.6-x86_64.tar.gz #在/usr/local目录下 #ln -s mys

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

linux下安装mysql数据库 linux版本:CentOS release 6.8 (Final) mysql版本:mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz 在安装数据库过成中,输入启动mysql命令:/usr/local/mysql/support-files/mysql.server start 报错信息如图: 进入/usr/local/mysql/data目录下查看报错日志: 经在网上查找解决方案,折腾了一翻还是不行,后来发现在初始化数据库步骤