凝思6.0.80(debian8)离线安装MySQL5.7.30

国网安全要求,电力系统必须使用国产操作系统

2021.6.21 凝思6.0.80 (此时最新)基于debian8,安装系统时选择intsall方式,除办公软件类全装,由于 80 系统配置软件过于落后(如mysql为5.5版本,gcc492,python3.4),所以只有自己升级了。本教程主要针对于mysql的升级。

由于凝思网络问题,这里使用手动升级的方式,使用deb安装包。对于凝思系统,不使用激活码不能联网,当然你可以联系他们的销售,会给你试用码。

本教程分为三步:

①卸载旧版mysql

②安装mysql5.7.5

③解决mysql配置问题

下面开始正式步骤:

1.卸载旧版Mysql

登录凝思OrDebian8服务器,获取 终端root权限后列出已安装的mysq的deb包

su
dpkg --list|grep mysql

我这边结果如下,需要依次卸载如下软件包,当然你的系统可能会有所不同,按照提示的依赖关系卸载即可,注意到mysql-common 和 libmysqlclient18:amd64也是5.5版本的,这两者不用卸载,安装新版以后,他们的版本会发生变化。

dpkg -r mysql-server
dpkg -r libmysqlclient-dev
dpkg -r mysql-server-5.5
dpkg -r mysql-client-5.5
dpkg -r mysql-server-core-5.5

卸载mysql5.5配置

dpkg --purge mysql-server-5.5

选择是,删除mysql数据,注意备份以前的数据。

致此,mysql5.5卸载完成。

2.安装Mysql5.7.30

首先去mysql社区版管网,发现debian8最高支持到mysql5.7.30,从官网下载mysql5.7.30的软件包。

点击进入下载地址

由于我这边是X86架构的工控机,所以选择AMD64版本,如果你使用ARM架构机器,可以下载ARM架构的版本。

解压mysql安装包,并按以下顺序安装:

tar -xvf mysql-server_5.7.30-1debian8_amd64.deb-bundle.tar 
dpkg -i mysql-common_5.7.30-1debian8_amd64.deb

安装mysql配置文件并设置登录信息

 dpkg-preconfigure mysql-community-server_5.7.30-1debian8_amd64.deb

此处输入数据库root用户的密码,接下来继续安装

dpkg -i libmysqlclient20_5.7.30-1debian8_amd64.deb
dpkg -i libmysqlclient-dev_5.7.30-1debian8_amd64.deb
dpkg -i libmysqld-dev_5.7.30-1debian8_amd64.deb
dpkg -i mysql-community-client_5.7.30-1debian8_amd64.deb
dpkg -i mysql-client_5.7.30-1debian8_amd64.deb
dpkg -i mysql-common_5.7.30-1debian8_amd64.deb

此处需要补一个libmecab2_0.996-1.1_amd64.deb的包才能继续,可以去这里下载。然后继续执行安装:

dpkg -i libmecab2_0.996-1.1_amd64.deb
dpkg -i mysql-community-server_5.7.30-1debian8_amd64.deb 
dpkg -i mysql-server_5.7.30-1debian8_amd64.deb

这时候mysql5.7.30已经安装完成,我们可以输入以下命令查看mysql版本

mysql -V

但是重启mysql会发现重启不成功,这是为什么呢?我们将在第三部分来解决这个问题。

3. 解决mysql配置问题

查看myql配置文件路径

mysql --help | grep my.cnf

结果如下

/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf 

查看这三个文件以后,发现其中的两个文件都不存在,而另一个文件/etc/mysql/my.cnf则是一个无效连接(和另一个文件互为软连接,怀疑是新老版本交替时的配置冲突)。

复制 /etc/mysql/my.cnf 的文本内容。

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
#
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
#
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
#
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

并删除原文件,新建 /etc/mysql/my.cnf文件,并写入如上复制的内容。

rm -f  /etc/mysql/my.cnf 
vi  /etc/mysql/my.cnf  

可以看到,真正的配置文件,在/etc/mysql/conf.d/ 和/etc/mysql/mysql.conf.d/ 两个文件夹中,实际就是/etc/mysql/mysql.conf.d/mysqld.cnf 。

启动还是失败,发现/usr/sbin/mysqld权限不对,是凝思系统级用户权限。我也不知道他弄着用户是干嘛的,也许是安全吧。

执行赋权操作

chmod 755 /usr/sbin/mysqld

接下来就可以重启mysql,并把mysql加入启动项

systemctl restart mysql 
systemctl enable mysql

本文完。