mysql 指定根目录 迁移根目录
- 1、问题描述
- 2、问题分析
- 3、解决方法
- 3.1、初始化mysql前就手动指定mysql根目录为一个大的分区(支持动态扩容),事前就根本上解决mysql根目录空间不够问题
- 3.2、发现mysql根目录爆满了,改变mysql根目录为一个大的分区(支持动态扩容),事后解决根目录空间不够问题(需要迁移之前的根目录数据到新的根目录)
1、问题描述
本博文以银河麒麟高级服务器操作系统v10 sp3为系统平台,安装mysql 8.0.35。
安装完mysql后,默认启动mysql后,默认的mysql根目录是/var/lib/mysql
查看mysql配置文件/etc/my.cnf 查看mysql根目录
cat /etc/my.cnf
其中 datadir=/var/lib/mysql 就是MySQL根目录,mysql所有的数据库文件都放在根目录下
在有些服务器上,/ 根目录空间非常小而且不能动态扩容,不能承载太多的mysql数据,随着mysql的运行,默认的mysql根目录是/var/lib/mysql 占用空间越来越大,导致/ 目录爆满,系统崩溃。(为什么不扩充根目录呢?因为在有些服务器上根目录不是LVM分区、不能动态扩容)
不修改默认的mysql配置文件,初始化mysql后,mysql根目录如下,查看mysql根目录的组织结构
ls -l /var/lib/mysql
整个根目录大小是90M(含有mysql默认的系统数据库:mysql、sys、performance_schema、information_schema,和其他的一些文件:比如密钥文件、mysql sock文件、mysql binlog文件等)
mysql默认的系统数据库:mysql、sys、performance_schema、information_schema
2、问题分析
有2个思路解决mysql根目录空间爆满的问题
1、整体规划,防患于未然
在mysql初始化前,通过修改mysql的配置文件/etc/my.cnf指定一个很大或者可以动态扩容的文件目录作为mysql根目录。
2、后知后觉,整体规划没做好,事后处理
如果在生产环境上,初始化mysql前没有手动指定mysql根目录,造成默认的mysql根目录就是/var/lib/mysql,并且环境已经运行一段时间发现mysql根目录空间不够了,这种情况下仍然可以通过修改mysql的配置文件/etc/my.cnf指定一个很大或者可以动态扩容的文件目录作为mysql根目录,只不过要把之前mysql根目录/var/lib/mysql 下的数据迁移到新的mysql根目录即可。
3、解决方法
3.1、初始化mysql前就手动指定mysql根目录为一个大的分区(支持动态扩容),事前就根本上解决mysql根目录空间不够问题
3.1.0、方法思路
在mysql启动前,先在mysql配置文件/etc/my.cnf中指定mysql根目录,这个根目录的空间要保证非常大,或者这个根目录是能够动态扩容的,比如LVM分区。
linux上mysql配置文件是/etc/my.cnf或者/etc/mysql/mysql.cnf [redhat系是/etc/my.cnf,debian系是/etc/mysql/mysql.cnf]。
windows上mysql配置文件是C:\my.ini。
本文以linux系统为例描述配置mysql根目录方法
参考链接: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/data-directory-initialization.html
在mysql初始化之前就修改默认mysql配置文件的内容以满足您的要求,然后再初始化mysql。
在linux系统上安装完成mysql后,先不要初始化mysql。
先编辑mysql配置文件/etc/my.cnf
cp /etc/my.cnf /etc/my.cnf.bak
vi /etc/my.cnf
修改datadir和socket参数
修改前
修改后
然后初始化mysql
systemctl start mysqld.service
安装过程如下
3.1.1、卸载mariadb
由于银河麒麟v10系统默认安装了mariadb 会与Mysql相冲突,因此首先需要卸载系统自带的mariadb
查看系统上默认安装的Mariadb软件包
使用yum查看已经安装的mariadb软件包
yum list --installed mariadb*
rpm -qa|grep -i mariadb*
查看默认的mariadb配置文件
在这里插入代码片
默认的配置文件是 /etc/my.cnf
查看默认的mariadb配置目录
find / -type d -name my.cnf*
使用yum卸载 mariadb
yum remove mariadb.x86_64 mariadb-common.x86_64 mariadb-connector-c.x86_64 mariadb-errmessage.x86_64 mariadb-server.x86_64
卸载记录
[root@localhost ~]# yum remove mariadb.x86_64 mariadb-common.x86_64 mariadb-connector-c.x86_64 mariadb-errmessage.x86_64 mariadb-server.x86_64
Dependencies resolved.
======================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================
Removing:
mariadb x86_64 3:10.3.9-12.p01.ky10 @anaconda 37 M
mariadb-common x86_64 3:10.3.9-12.p01.ky10 @anaconda 179 k
mariadb-connector-c x86_64 3.0.6-8.ky10 @anaconda 413 k
mariadb-errmessage x86_64 3:10.3.9-12.p01.ky10 @anaconda 2.3 M
mariadb-server x86_64 3:10.3.9-12.p01.ky10 @anaconda 91 M
Removing dependent packages:
fcitx-chewing x86_64 0.2.3-8.ky10 @anaconda 65 k
fcitx-configtool x86_64 0.4.10-6.p01.ky10 @anaconda 239 k
fcitx-pinyin x86_64 4.2.9.1-2.p03.ky10 @anaconda 7.1 M
fcitx-qt5-devel x86_64 1.2.4-3.1.ky10 @anaconda 57 k
ipmitool x86_64 1.8.18-15.ky10 @anaconda 1.4 M
kylin-activation x86_64 1.3.10-5.p27.ky10 @anaconda 553 k
python2-mysqlclient x86_64 1.3.12-8.ky10 @anaconda 349 k
rsyslog-relp x86_64 8.2006.0-7.p01.ky10 @anaconda 62 k
security-tool x86_64 2.0-1.75.p01.ky10 @anaconda 45 k
Removing unused dependencies:
assimp x86_64 3.3.1-19.ky10 @anaconda 7.1 M
fcitx x86_64 4.2.9.1-2.p03.ky10 @anaconda 1.0 M
fcitx-data noarch 4.2.9.1-2.p03.ky10 @anaconda 5.3 M
fcitx-gtk2 x86_64 4.2.9.1-2.p03.ky10 @anaconda 34 k
fcitx-gtk3 x86_64 4.2.9.1-2.p03.ky10 @anaconda 34 k
fcitx-libs x86_64 4.2.9.1-2.p03.ky10 @anaconda 1.6 M
fcitx-qt5 x86_64 1.2.4-3.1.ky10 @anaconda 626 k
firebird x86_64 3.0.3.32900-9.p02.ky10 @anaconda 18 M
freetds x86_64 1.00.38-8.ky10 @anaconda 2.6 M
gsm x86_64 1.0.18-4.ky10 @anaconda 95 k
gstreamer1-plugins-bad-free x86_64 1.16.2-2.ky10 @anaconda 5.7 M
ipmitool-help noarch 1.8.18-15.ky10 @anaconda 92 k
irrlicht x86_64 1.8.4-11.ky10 @anaconda 5.3 M
kf5-filesystem x86_64 5.59.0-1.1.ky10 @anaconda 0
kf5-kwindowsystem x86_64 5.55.0-1.p01.ky10 @anaconda 488 k
libaesgm x86_64 20090429-21.ky10 @anaconda 118 k
libchewing x86_64 0.5.1-17.ky10 @anaconda 3.7 M
libestr x86_64 0.1.11-1.ky10 @anaconda 43 k
libfastjson x86_64 0.99.9-1.ky10 @anaconda 72 k
libmng x86_64 2.0.3-10.ky10 @anaconda 633 k
libnet x86_64 1.2-1.ky10 @anaconda 98 k
libnice x86_64 0.1.14-10.ky10 @anaconda 455 k
librelp x86_64 1.2.16-3.ky10 @anaconda 157 k
libtommath x86_64 1.0.1-5.ky10 @anaconda 76 k
minizip x86_64 1.2.11-18.ky10 @anaconda 49 k
net-snmp x86_64 1:5.9-4.p01.ky10 @anaconda 4.8 M
net-snmp-help noarch 1:5.9-4.p01.ky10 @anaconda 904 k
perl-DBD-MySQL x86_64 4.046-6.ky10 @anaconda 333 k
poly2tri x86_64 0.0-19.ky10 @anaconda 54 k
postgresql-libs x86_64 10.5-22.ky10 @anaconda 897 k
qt x86_64 1:4.8.7-47.p04.ky10 @anaconda 351 M
qt5 noarch 5.14.2-1.ky10 @anaconda 19
qt5-qdbusviewer x86_64 5.11.1-5.p03.ky10 @anaconda 137 k
qt5-qt3d x86_64 5.11.1-4.ky10 @anaconda 7.3 M
qt5-qtbase-mysql x86_64 5.11.1-13.p01.ky10 @anaconda 79 k
qt5-qtbase-postgresql x86_64 5.11.1-13.p01.ky10 @anaconda 87 k
qt5-qtconnectivity x86_64 5.11.1-4.ky10 @anaconda 1.6 M
qt5-qtdoc noarch 5.11.1-4.ky10 @anaconda 8.0 M
qt5-qtgraphicaleffects x86_64 5.11.1-5.p01.ky10 @anaconda 645 k
qt5-qtimageformats x86_64 5.11.1-6.p01.ky10 @anaconda 374 k
qt5-qtlocation x86_64 5.11.1-6.ky10 @anaconda 10 M
qt5-qtmultimedia x86_64 5.11.1-6.ky10 @anaconda 2.8 M
qt5-qtquickcontrols x86_64 5.11.1-5.ky10 @anaconda 4.7 M
qt5-qtquickcontrols2 x86_64 5.11.1-4.ky10 @anaconda 6.8 M
qt5-qtscript x86_64 5.11.1-5.ky10 @anaconda 3.3 M
qt5-qtsensors x86_64 5.11.1-6.ky10 @anaconda 1.7 M
qt5-qtserialport x86_64 5.11.1-5.p01.ky10 @anaconda 216 k
qt5-qtwayland x86_64 5.11.1-6.ky10 @anaconda 3.3 M
qt5-qtwebchannel x86_64 5.11.1-5.ky10 @anaconda 261 k
qt5-qtwebsockets x86_64 5.11.1-6.ky10 @anaconda 274 k
rsyslog x86_64 8.2006.0-7.p01.ky10 @anaconda 2.6 M
unixODBC x86_64 2.3.7-3.ky10 @anaconda 1.3 M
Transaction Summary
======================================================================================================================================================================================
Remove 66 Packages
Freed space: 609 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: fcitx-configtool-0.4.10-6.p01.ky10.x86_64 1/1
Erasing : fcitx-configtool-0.4.10-6.p01.ky10.x86_64 1/66
Erasing : mariadb-3:10.3.9-12.p01.ky10.x86_64 2/66
Running scriptlet: mariadb-server-3:10.3.9-12.p01.ky10.x86_64 3/66
Erasing : mariadb-server-3:10.3.9-12.p01.ky10.x86_64 3/66
Running scriptlet: mariadb-server-3:10.3.9-12.p01.ky10.x86_64 3/66
Erasing : fcitx-pinyin-4.2.9.1-2.p03.ky10.x86_64 4/66
Erasing : fcitx-chewing-0.2.3-8.ky10.x86_64 5/66
Erasing : mariadb-errmessage-3:10.3.9-12.p01.ky10.x86_64 6/66
Running scriptlet: security-tool-2.0-1.75.p01.ky10.x86_64 7/66
Erasing : security-tool-2.0-1.75.p01.ky10.x86_64 7/66
warning: /etc/kylin_security/security saved as /etc/kylin_security/security.rpmsave
Running scriptlet: security-tool-2.0-1.75.p01.ky10.x86_64 7/66
Erasing : fcitx-qt5-devel-1.2.4-3.1.ky10.x86_64 8/66
Erasing : fcitx-4.2.9.1-2.p03.ky10.x86_64 9/66
Running scriptlet: fcitx-4.2.9.1-2.p03.ky10.x86_64 9/66
Erasing : fcitx-qt5-1.2.4-3.1.ky10.x86_64 10/66
Erasing : fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64 11/66
Running scriptlet: fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64 11/66
/var/tmp/rpm-tmp.yjxvOw: line 1: /usr/bin/update-gtk-immodules: No such file or directory
Erasing : fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 12/66
Running scriptlet: fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 12/66
Erasing : fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 13/66
Running scriptlet: fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 13/66
Erasing : qt-1:4.8.7-47.p04.ky10.x86_64 14/66
Running scriptlet: qt-1:4.8.7-47.p04.ky10.x86_64 14/66
Erasing : freetds-1.00.38-8.ky10.x86_64 15/66
Running scriptlet: freetds-1.00.38-8.ky10.x86_64 15/66
Erasing : perl-DBD-MySQL-4.046-6.ky10.x86_64 16/66
Erasing : rsyslog-relp-8.2006.0-7.p01.ky10.x86_64 17/66
Running scriptlet: rsyslog-8.2006.0-7.p01.ky10.x86_64 18/66
Removed /etc/systemd/system/multi-user.target.wants/rsyslog.service.
Erasing : rsyslog-8.2006.0-7.p01.ky10.x86_64 18/66
Running scriptlet: rsyslog-8.2006.0-7.p01.ky10.x86_64 18/66
Erasing : python2-mysqlclient-1.3.12-8.ky10.x86_64 19/66
Erasing : kylin-activation-1.3.10-5.p27.ky10.x86_64 20/66
Erasing : qt5-5.14.2-1.ky10.noarch 21/66
Erasing : qt5-qt3d-5.11.1-4.ky10.x86_64 22/66
Running scriptlet: qt5-qt3d-5.11.1-4.ky10.x86_64 22/66
Erasing : assimp-3.3.1-19.ky10.x86_64 23/66
Running scriptlet: assimp-3.3.1-19.ky10.x86_64 23/66
Erasing : qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 24/66
Running scriptlet: ipmitool-1.8.18-15.ky10.x86_64 25/66
Erasing : ipmitool-1.8.18-15.ky10.x86_64 25/66
Running scriptlet: ipmitool-1.8.18-15.ky10.x86_64 25/66
Erasing : ipmitool-help-1.8.18-15.ky10.noarch 26/66
Erasing : qt5-qtdoc-5.11.1-4.ky10.noarch 27/66
Erasing : fcitx-data-4.2.9.1-2.p03.ky10.noarch 28/66
Running scriptlet: fcitx-data-4.2.9.1-2.p03.ky10.noarch 28/66
Erasing : mariadb-common-3:10.3.9-12.p01.ky10.x86_64 29/66
Running scriptlet: net-snmp-1:5.9-4.p01.ky10.x86_64 30/66
Erasing : net-snmp-1:5.9-4.p01.ky10.x86_64 30/66
Running scriptlet: net-snmp-1:5.9-4.p01.ky10.x86_64 30/66
Erasing : irrlicht-1.8.4-11.ky10.x86_64 31/66
Running scriptlet: irrlicht-1.8.4-11.ky10.x86_64 31/66
Erasing : qt5-qtimageformats-5.11.1-6.p01.ky10.x86_64 32/66
Erasing : qt5-qtbase-postgresql-5.11.1-13.p01.ky10.x86_64 33/66
Erasing : qt5-qtmultimedia-5.11.1-6.ky10.x86_64 34/66
Running scriptlet: qt5-qtmultimedia-5.11.1-6.ky10.x86_64 34/66
Erasing : gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64 35/66
Running scriptlet: gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64 35/66
Erasing : qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 36/66
Running scriptlet: qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 36/66
Erasing : kf5-kwindowsystem-5.55.0-1.p01.ky10.x86_64 37/66
Running scriptlet: firebird-3.0.3.32900-9.p02.ky10.x86_64 38/66
Erasing : firebird-3.0.3.32900-9.p02.ky10.x86_64 38/66
Running scriptlet: firebird-3.0.3.32900-9.p02.ky10.x86_64 38/66
Erasing : kf5-filesystem-5.59.0-1.1.ky10.x86_64 39/66
Erasing : net-snmp-help-1:5.9-4.p01.ky10.noarch 40/66
Erasing : libtommath-1.0.1-5.ky10.x86_64 41/66
Erasing : qt5-qtgraphicaleffects-5.11.1-5.p01.ky10.x86_64 42/66
Erasing : gsm-1.0.18-4.ky10.x86_64 43/66
Erasing : libnice-0.1.14-10.ky10.x86_64 44/66
Running scriptlet: libnice-0.1.14-10.ky10.x86_64 44/66
Erasing : postgresql-libs-10.5-22.ky10.x86_64 45/66
Running scriptlet: postgresql-libs-10.5-22.ky10.x86_64 45/66
Erasing : libmng-2.0.3-10.ky10.x86_64 46/66
Running scriptlet: libmng-2.0.3-10.ky10.x86_64 46/66
Erasing : libaesgm-20090429-21.ky10.x86_64 47/66
Running scriptlet: libaesgm-20090429-21.ky10.x86_64 47/66
Erasing : mariadb-connector-c-3.0.6-8.ky10.x86_64 48/66
Erasing : minizip-1.2.11-18.ky10.x86_64 49/66
Erasing : poly2tri-0.0-19.ky10.x86_64 50/66
Erasing : qt5-qdbusviewer-5.11.1-5.p03.ky10.x86_64 51/66
Erasing : qt5-qtconnectivity-5.11.1-4.ky10.x86_64 52/66
Erasing : qt5-qtlocation-5.11.1-6.ky10.x86_64 53/66
Running scriptlet: qt5-qtlocation-5.11.1-6.ky10.x86_64 53/66
Erasing : qt5-qtquickcontrols-5.11.1-5.ky10.x86_64 54/66
Erasing : qt5-qtscript-5.11.1-5.ky10.x86_64 55/66
Erasing : qt5-qtsensors-5.11.1-6.ky10.x86_64 56/66
Erasing : qt5-qtserialport-5.11.1-5.p01.ky10.x86_64 57/66
Erasing : qt5-qtwayland-5.11.1-6.ky10.x86_64 58/66
Erasing : qt5-qtwebchannel-5.11.1-5.ky10.x86_64 59/66
Erasing : qt5-qtwebsockets-5.11.1-6.ky10.x86_64 60/66
Erasing : libestr-0.1.11-1.ky10.x86_64 61/66
Running scriptlet: libestr-0.1.11-1.ky10.x86_64 61/66
Erasing : libfastjson-0.99.9-1.ky10.x86_64 62/66
Running scriptlet: libfastjson-0.99.9-1.ky10.x86_64 62/66
Erasing : libnet-1.2-1.ky10.x86_64 63/66
Running scriptlet: libnet-1.2-1.ky10.x86_64 63/66
Erasing : librelp-1.2.16-3.ky10.x86_64 64/66
Running scriptlet: librelp-1.2.16-3.ky10.x86_64 64/66
Erasing : unixODBC-2.3.7-3.ky10.x86_64 65/66
Running scriptlet: unixODBC-2.3.7-3.ky10.x86_64 65/66
Erasing : libchewing-0.5.1-17.ky10.x86_64 66/66
Running scriptlet: libchewing-0.5.1-17.ky10.x86_64 66/66
Verifying : assimp-3.3.1-19.ky10.x86_64 1/66
Verifying : fcitx-4.2.9.1-2.p03.ky10.x86_64 2/66
Verifying : fcitx-chewing-0.2.3-8.ky10.x86_64 3/66
Verifying : fcitx-configtool-0.4.10-6.p01.ky10.x86_64 4/66
Verifying : fcitx-data-4.2.9.1-2.p03.ky10.noarch 5/66
Verifying : fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64 6/66
Verifying : fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 7/66
Verifying : fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 8/66
Verifying : fcitx-pinyin-4.2.9.1-2.p03.ky10.x86_64 9/66
Verifying : fcitx-qt5-1.2.4-3.1.ky10.x86_64 10/66
Verifying : fcitx-qt5-devel-1.2.4-3.1.ky10.x86_64 11/66
Verifying : firebird-3.0.3.32900-9.p02.ky10.x86_64 12/66
Verifying : freetds-1.00.38-8.ky10.x86_64 13/66
Verifying : gsm-1.0.18-4.ky10.x86_64 14/66
Verifying : gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64 15/66
Verifying : ipmitool-1.8.18-15.ky10.x86_64 16/66
Verifying : ipmitool-help-1.8.18-15.ky10.noarch 17/66
Verifying : irrlicht-1.8.4-11.ky10.x86_64 18/66
Verifying : kf5-filesystem-5.59.0-1.1.ky10.x86_64 19/66
Verifying : kf5-kwindowsystem-5.55.0-1.p01.ky10.x86_64 20/66
Verifying : kylin-activation-1.3.10-5.p27.ky10.x86_64 21/66
Verifying : libaesgm-20090429-21.ky10.x86_64 22/66
Verifying : libchewing-0.5.1-17.ky10.x86_64 23/66
Verifying : libestr-0.1.11-1.ky10.x86_64 24/66
Verifying : libfastjson-0.99.9-1.ky10.x86_64 25/66
Verifying : libmng-2.0.3-10.ky10.x86_64 26/66
Verifying : libnet-1.2-1.ky10.x86_64 27/66
Verifying : libnice-0.1.14-10.ky10.x86_64 28/66
Verifying : librelp-1.2.16-3.ky10.x86_64 29/66
Verifying : libtommath-1.0.1-5.ky10.x86_64 30/66
Verifying : mariadb-3:10.3.9-12.p01.ky10.x86_64 31/66
Verifying : mariadb-common-3:10.3.9-12.p01.ky10.x86_64 32/66
Verifying : mariadb-connector-c-3.0.6-8.ky10.x86_64 33/66
Verifying : mariadb-errmessage-3:10.3.9-12.p01.ky10.x86_64 34/66
Verifying : mariadb-server-3:10.3.9-12.p01.ky10.x86_64 35/66
Verifying : minizip-1.2.11-18.ky10.x86_64 36/66
Verifying : net-snmp-1:5.9-4.p01.ky10.x86_64 37/66
Verifying : net-snmp-help-1:5.9-4.p01.ky10.noarch 38/66
Verifying : perl-DBD-MySQL-4.046-6.ky10.x86_64 39/66
Verifying : poly2tri-0.0-19.ky10.x86_64 40/66
Verifying : postgresql-libs-10.5-22.ky10.x86_64 41/66
Verifying : python2-mysqlclient-1.3.12-8.ky10.x86_64 42/66
Verifying : qt-1:4.8.7-47.p04.ky10.x86_64 43/66
Verifying : qt5-5.14.2-1.ky10.noarch 44/66
Verifying : qt5-qdbusviewer-5.11.1-5.p03.ky10.x86_64 45/66
Verifying : qt5-qt3d-5.11.1-4.ky10.x86_64 46/66
Verifying : qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 47/66
Verifying : qt5-qtbase-postgresql-5.11.1-13.p01.ky10.x86_64 48/66
Verifying : qt5-qtconnectivity-5.11.1-4.ky10.x86_64 49/66
Verifying : qt5-qtdoc-5.11.1-4.ky10.noarch 50/66
Verifying : qt5-qtgraphicaleffects-5.11.1-5.p01.ky10.x86_64 51/66
Verifying : qt5-qtimageformats-5.11.1-6.p01.ky10.x86_64 52/66
Verifying : qt5-qtlocation-5.11.1-6.ky10.x86_64 53/66
Verifying : qt5-qtmultimedia-5.11.1-6.ky10.x86_64 54/66
Verifying : qt5-qtquickcontrols-5.11.1-5.ky10.x86_64 55/66
Verifying : qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 56/66
Verifying : qt5-qtscript-5.11.1-5.ky10.x86_64 57/66
Verifying : qt5-qtsensors-5.11.1-6.ky10.x86_64 58/66
Verifying : qt5-qtserialport-5.11.1-5.p01.ky10.x86_64 59/66
Verifying : qt5-qtwayland-5.11.1-6.ky10.x86_64 60/66
Verifying : qt5-qtwebchannel-5.11.1-5.ky10.x86_64 61/66
Verifying : qt5-qtwebsockets-5.11.1-6.ky10.x86_64 62/66
Verifying : rsyslog-8.2006.0-7.p01.ky10.x86_64 63/66
Verifying : rsyslog-relp-8.2006.0-7.p01.ky10.x86_64 64/66
Verifying : security-tool-2.0-1.75.p01.ky10.x86_64 65/66
Verifying : unixODBC-2.3.7-3.ky10.x86_64 66/66
Removed:
assimp-3.3.1-19.ky10.x86_64 fcitx-4.2.9.1-2.p03.ky10.x86_64 fcitx-chewing-0.2.3-8.ky10.x86_64
fcitx-configtool-0.4.10-6.p01.ky10.x86_64 fcitx-data-4.2.9.1-2.p03.ky10.noarch fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64
fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 fcitx-pinyin-4.2.9.1-2.p03.ky10.x86_64
fcitx-qt5-1.2.4-3.1.ky10.x86_64 fcitx-qt5-devel-1.2.4-3.1.ky10.x86_64 firebird-3.0.3.32900-9.p02.ky10.x86_64
freetds-1.00.38-8.ky10.x86_64 gsm-1.0.18-4.ky10.x86_64 gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64
ipmitool-1.8.18-15.ky10.x86_64 ipmitool-help-1.8.18-15.ky10.noarch irrlicht-1.8.4-11.ky10.x86_64
kf5-filesystem-5.59.0-1.1.ky10.x86_64 kf5-kwindowsystem-5.55.0-1.p01.ky10.x86_64 kylin-activation-1.3.10-5.p27.ky10.x86_64
libaesgm-20090429-21.ky10.x86_64 libchewing-0.5.1-17.ky10.x86_64 libestr-0.1.11-1.ky10.x86_64
libfastjson-0.99.9-1.ky10.x86_64 libmng-2.0.3-10.ky10.x86_64 libnet-1.2-1.ky10.x86_64
libnice-0.1.14-10.ky10.x86_64 librelp-1.2.16-3.ky10.x86_64 libtommath-1.0.1-5.ky10.x86_64
mariadb-3:10.3.9-12.p01.ky10.x86_64 mariadb-common-3:10.3.9-12.p01.ky10.x86_64 mariadb-connector-c-3.0.6-8.ky10.x86_64
mariadb-errmessage-3:10.3.9-12.p01.ky10.x86_64 mariadb-server-3:10.3.9-12.p01.ky10.x86_64 minizip-1.2.11-18.ky10.x86_64
net-snmp-1:5.9-4.p01.ky10.x86_64 net-snmp-help-1:5.9-4.p01.ky10.noarch perl-DBD-MySQL-4.046-6.ky10.x86_64
poly2tri-0.0-19.ky10.x86_64 postgresql-libs-10.5-22.ky10.x86_64 python2-mysqlclient-1.3.12-8.ky10.x86_64
qt-1:4.8.7-47.p04.ky10.x86_64 qt5-5.14.2-1.ky10.noarch qt5-qdbusviewer-5.11.1-5.p03.ky10.x86_64
qt5-qt3d-5.11.1-4.ky10.x86_64 qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 qt5-qtbase-postgresql-5.11.1-13.p01.ky10.x86_64
qt5-qtconnectivity-5.11.1-4.ky10.x86_64 qt5-qtdoc-5.11.1-4.ky10.noarch qt5-qtgraphicaleffects-5.11.1-5.p01.ky10.x86_64
qt5-qtimageformats-5.11.1-6.p01.ky10.x86_64 qt5-qtlocation-5.11.1-6.ky10.x86_64 qt5-qtmultimedia-5.11.1-6.ky10.x86_64
qt5-qtquickcontrols-5.11.1-5.ky10.x86_64 qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 qt5-qtscript-5.11.1-5.ky10.x86_64
qt5-qtsensors-5.11.1-6.ky10.x86_64 qt5-qtserialport-5.11.1-5.p01.ky10.x86_64 qt5-qtwayland-5.11.1-6.ky10.x86_64
qt5-qtwebchannel-5.11.1-5.ky10.x86_64 qt5-qtwebsockets-5.11.1-6.ky10.x86_64 rsyslog-8.2006.0-7.p01.ky10.x86_64
rsyslog-relp-8.2006.0-7.p01.ky10.x86_64 security-tool-2.0-1.75.p01.ky10.x86_64 unixODBC-2.3.7-3.ky10.x86_64
Complete!
[root@localhost ~]#
验证卸载Mariadb成功
yum list --installed mariadb*
rpm -qa|grep -i mariadb*
查看Mariadb配置文件和目录是否还存在 已经不存在了
ls -l /etc/my.cnf
ls -l /etc/my.cnf.d
至此mariadb卸载完成
3.1.2、下载Mysql安装包
访问官网下载链接 链接: https://dev.mysql.com/downloads/mysql/
选择如下 点击下载按钮 下载安装包
选择 mysql-8.0.35-1.el8.x86_64.rpm-bundle.tar 点击下载
为什么选择redhat 8的操作系统版本呢?
https://www.kylinos.cn/about/news/814.html
通过查询麒麟官网得知,银河麒麟高级服务器操作系统是兼容centos8的,centos8和redhat8兼容。
3.1.3、安装Mysql 8.35
官方安装文档
链接: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/linux-installation-rpm.html
RPM Packages for MySQL Community Edition
Package Name | Summary |
---|---|
mysql-community-client | MySQL client applications and tools |
mysql-community-client-plugins | Shared plugins for MySQL client applications |
mysql-community-common | Common files for server and client libraries |
mysql-community-devel | Development header files and libraries for MySQL database client applications |
mysql-community-embedded-compat | MySQL server as an embedded library with compatibility for applications using version 18 of the library |
mysql-community-icu-data-files | MySQL packaging of ICU data files needed by MySQL regular expressions |
mysql-community-libs | Shared libraries for MySQL database client applications |
mysql-community-libs-compat | Shared compatibility libraries for previous MySQL installations; only present if previous MySQL versions are supported by the platform |
mysql-community-server | Database server and related tools |
mysql-community-server-debug | Debug server and plugin binaries |
mysql-community-test | Test suite for the MySQL server |
mysql-community | The source code RPM looks similar to mysql-community-8.0.35-1.el7.src.rpm, depending on selected OS |
Additional debuginfo RPMs | There are several debuginfo packages: mysql-community-client-debuginfo, mysql-community-libs-debuginfo mysql-community-server-debug-debuginfo mysql-community-server-debuginfo, and mysql-community-test-debuginfo. |
rpm包的名称格式:packagename-version-distribution-arch.rpm
安装步骤如下:
创建Mysql安装包目录
mkdir -p /root/package/mysql
上传Mysql安装包mysql-8.0.35-1.el8.x86_64.rpm-bundle.tar 到/root/package/mysql 目录下
cd /root/package/mysql
mkdir mysql-8.0.35-1.el8.x86_64.rpm-bundle
安装过程如下
tar -xvf mysql-8.0.35-1.el8.x86_64.rpm-bundle.tar -C mysql-8.0.35-1.el8.x86_64.rpm-bundle/
cd mysql-8.0.35-1.el8.x86_64.rpm-bundle/
只需要安装以下软件包即可
In most cases, you need to install the mysql-community-server, mysql-community-client, mysql-community-client-plugins, mysql-community-libs, mysql-community-icu-data-files, mysql-community-common, and mysql-community-libs-compat packages to get a functional, standard MySQL installation. To perform such a standard, basic installation, go to the folder that contains all those packages (and, preferably, no other RPM packages with similar names), and issue the following command:
意思是说这个软件包目录下只包含有上面提到的这几个包即可,不能有其他的包,因此把其他的包删除掉。只保留
mysql-community-server, mysql-community-client, mysql-community-client-plugins, mysql-community-libs, mysql-community-icu-data-files, mysql-community-common, and mysql-community-libs-compat
rm -f mysql-community-server-debug*
rm -f mysql-community-debug*
rm -f mysql-community-client-debuginfo-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-test-*
rm -f mysql-community-client-plugins-debuginfo-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-devel-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-libs-debuginfo-8.0.35-1.el8.x86_64.rpm
安装mysql前,操作系统上没有没有默认的mysql根目录/var/lib/mysql、,mysql配置文件/etc/my.cnf
yum install mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-*
安装完成如图所示
查看安装的mysql包
yum list --installed |grep -i mysql
rpm -qa|grep -i mysql
安装完成后,会形成以下文件和目录(执行安装命令后才会形成以下文件和目录)
安装mysql后为什么就会形成以下文件和目录呢?
这是因为所谓的安装mysql,安装mysql这个动作所做的操作是:把mysql安装包中的文件目录结构复制到安装mysql的操作系统上,仅此而已。mysql安装包里面本就有以下这些文件和目录。
Files or Resources | Location |
---|---|
Files or Resources | Location |
Client programs and scripts | /usr/bin |
mysqld server | /usr/sbin |
Configuration file | /etc/my.cnf |
Data directory | /var/lib/mysql |
Error log file | For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log |
Value of secure_file_priv | /var/lib/mysql-files |
System V init script | For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld |
Systemd service | For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld |
Pid file | /var/run/mysqld/mysqld.pid |
Socket | /var/lib/mysql/mysql.sock |
Keyring directory | /var/lib/mysql-keyring |
Unix manual pages | /usr/share/man |
Include (header) files | /usr/include/mysql |
Libraries | /usr/lib64/mysql |
Miscellaneous support files (for example, error messages, and character set files) | /usr/share/mysql |
安装完后 也会产生一个名为mysql 的系统用户,和一个名为mysql 的系统用户组。
至此安装Mysql 8.35完成。
如果在安装过程中出现问题,您可能会在错误日志文件/var/log/mysqld.log中找到日志信息。
安装成功的情况下 /var/log/mysqld.log是空的
如果需要切换到Mysql用户 使用如下命令
su - mysql --shell=/bin/bash
下面这项是可选的 看调试信息才需要这样启动Mysql,一般不需要。
Debug Package. A special variant of MySQL Server compiled with the debug package has been included in the server RPM packages. It performs debugging and memory allocation checks and produces a trace file when the server is running. To use that debug version, start MySQL with /usr/sbin/mysqld-debug, instead of starting it as a service or with /usr/sbin/mysqld. See The DBUG Package for the debug options you can use.
查看安装mysql后形成的目录和文件以及默认的配置文件
1、Client programs and scripts
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/bin目录下的东西
和mysql安装包mysql-community-client-8.0.35-1.el8.x86_64.rpm里面的/usr/bin目录下的东西
2、mysqld server
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的东西
3、Configuration file
安装mysql后为什么就会创建mysql的配置文件/etc/my.cnf呢?
这是因为mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm,这个包里面的目录结构如下
所谓的安装mysql,安装mysql这个动作所做的操作是:把mysql安装包中的文件目录结构复制到安装mysql的操作系统上,仅此而已。
4、Data directory
安装mysql后,mysql根目录/var/lib/msyql里面是空的。说明此时还没有初始化mysql,仅仅是安装完成了mysql而已。
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql文件夹
5、Error log file
/var/log/mysqld.log不是从mysql安装包拷贝的,是安装mysql时在操作系统上新建的这个文件,看这个文件的日期就是安装mysql的日期,和其他文件夹比如mysql根目录/var/lib/mysql、/var/lib/mysql-files的日期是不一样的。
6、Value of secure_file_priv
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql-files文件夹
7、System V init script
安装包里没有这个文件夹,也可能因为此次安装Mysql使用的是银河麒麟高级服务器操作系统v10 sp3,属于systemd系列的操作系统,所以并没有创建system v的启动脚本吧。不深究了,不影响。
8、Systemd service
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/usrl/ib/systemd/system文件夹下的mysqld.service文件。
9、Pid file
mysql还没有启动,所以没有mysql的pid文件。
10、Socket
mysql还没有启动,所以没有mysql的socket文件。
11、Keyring directory
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql-keyring文件夹
12、Unix manual pages
/usr/share/man
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/share/man目录下的东西
对应mysql安装包mysql-community-client-8.0.35-1.el8.x86_64.rpm里面的/usr/shar/man文件夹
13、Include (header) files
14、Libraries
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/lib64目录下的东西
15、Miscellaneous support files (for example, error messages, and character set files)、
3.1.4、初始化(启动)mysql 8.0.35
对于使用rpm包或deb包安装mysql的,启动mysql时就会执行初始化。本文是用rpm包安装的mysql,因此启动mysql服务就会初始化mysql。
安装后默认不会启动Mysql服务
在linux系统上安装完成mysql后,先不要初始化mysql。
先编辑mysql配置文件/etc/my.cnf
cp /etc/my.cnf /etc/my.cnf.bak
vi /etc/my.cnf
修改datadir和socket参数
修改前
修改后
然后初始化mysql,使用rpm包或deb包安装mysql的,启动mysql时就会执行初始化。本文是用rpm包安装的mysql,因此启动mysql服务即可。
注意启动mysql服务前/var/lib/mysql下是空的,并且没有/home/mysql文件夹
启动mysql命令
systemctl start mysqld.service
此启动mysql命令做下面这些事情
- 初始化mysql服务
- 检查有没有mysql根目录存在,如果没有mysql根目录存在,则创建mysql根目录。然后在mysql根目录下创建mysql的系统数据库:默认的系统数据库:mysql、sys、performance_schema、information_schema。
- 产生ssl证书和密钥在Mysql数据目录下
- validate_password默认安装。validate_password实现的默认密码策略要求密码至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,并且密码总长度至少为8个字符。
- 已创建超级用户帐户“root”@“localhost”。超级用户的密码已设置并存储在错误日志文件中。查看mysql的root账户默认密码
grep 'temporary password' /var/log/mysqld.log
1、查看数据目录
启动mysql服务前/var/lib/mysql下是空的,并且没有/home/mysql文件夹
启动mysql服务后/var/lib/mysql下仍然是空的,并且产生了/home/mysql文件夹,/home/mysql文件夹的大小是192M。(里面包含了初始化mysql时形成的mysql系统数据库以及密钥文件等)
查看mysql根目录/home/mysql下各个子文件夹
2、证书在数据目录下
3、查看 超级用户帐户“root”@“localhost” 的默认密码 vefxpw?ag6Ww
grep 'temporary password' /var/log/mysqld.log
4、启动Mysql后 会形成sock文件和pid文件
ls -lh /home/mysql/mysql.sock
ls -lh /var/run/mysqld/mysqld.pid
cat /var/run/mysqld/mysqld.pid
安装mysql后默认是监听在“:::3306”上的,这个表示ipv6监听,同时也包含了ipv4,也就说,ipv6和ipv4都支持访问mysql。
netstat -antlp|grep 3306
停止mysql服务后 sock文件和pid文件都消失了
开启mysql服务后 sock文件和pid文件重新生成了 只不过pid文件的数值不同了。
5、查看启动日志
cat /var/log/mysqld.log
下面是第一次启动mysql服务的日志 含有初始化日志:[System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 70838
初始化后停止mysql服务,再次开启mysql服务就不会有初始化日志了,只会有启动日志。
3.1.5、安装后配置
链接: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/postinstallation.html
使用安装Mysql数据库 时生成的默认密码登录mysql数据库
mysql -uroot -p
报错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
配置文件已经指定了socket=/home/mysql/mysql.sock 不知道为什么mysql还是去找默认的socket文件/var/lib/mysql/mysql.sock
socket=/home/mysql/mysql.sock
在登录mysql时使用-S参数手动指定正确的socket文件即可
mysql -uroot -p -S /home/mysql/mysql.sock
这个问题可以通过 创建一个软连接文件名为/var/lib/mysql/mysql.sock 连接到 迁移目录后新的mysql.sock文件,这样之后登录mysql时就不用添加-S参数了。
ln -s /home/mysql/mysql.sock /var/lib/mysql/mysql.sock
没修改默认密码前不能进行数据库sql操作
修改Mysql默认密码为Mysql@123
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql@123' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> use mysql;
Database changed
mysql>
mysql> update user set host = "%" where user = "root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql@123';
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
修改密码后即可成功执行数据库sql命令
使用新密码登录mysql数据库
实际生产环境使用mysql时,发现导入一些数据表后 mysql根目录所在的/home分区 就增大了差不多1G。后期mysql会产生更多的数据会占用很多空间,因此在启动mysql服务前先编辑配置文件选择一个大的分区作为mysql根目录是很重要的。
3.2、发现mysql根目录爆满了,改变mysql根目录为一个大的分区(支持动态扩容),事后解决根目录空间不够问题(需要迁移之前的根目录数据到新的根目录)
3.2.1、正常安装mysql后 mysql根目录是/var/lib/mysql
3.2.1.1、卸载mariadb
由于银河麒麟v10系统默认安装了mariadb 会与Mysql相冲突,因此首先需要卸载系统自带的mariadb
查看系统上默认安装的Mariadb软件包
使用yum查看已经安装的mariadb软件包
yum list --installed mariadb*
rpm -qa|grep -i mariadb*
查看默认的mariadb配置文件
在这里插入代码片
默认的配置文件是 /etc/my.cnf
查看默认的mariadb配置目录
find / -type d -name my.cnf*
使用yum卸载 mariadb
yum remove mariadb.x86_64 mariadb-common.x86_64 mariadb-connector-c.x86_64 mariadb-errmessage.x86_64 mariadb-server.x86_64
卸载记录
[root@localhost ~]# yum remove mariadb.x86_64 mariadb-common.x86_64 mariadb-connector-c.x86_64 mariadb-errmessage.x86_64 mariadb-server.x86_64
Dependencies resolved.
======================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================
Removing:
mariadb x86_64 3:10.3.9-12.p01.ky10 @anaconda 37 M
mariadb-common x86_64 3:10.3.9-12.p01.ky10 @anaconda 179 k
mariadb-connector-c x86_64 3.0.6-8.ky10 @anaconda 413 k
mariadb-errmessage x86_64 3:10.3.9-12.p01.ky10 @anaconda 2.3 M
mariadb-server x86_64 3:10.3.9-12.p01.ky10 @anaconda 91 M
Removing dependent packages:
fcitx-chewing x86_64 0.2.3-8.ky10 @anaconda 65 k
fcitx-configtool x86_64 0.4.10-6.p01.ky10 @anaconda 239 k
fcitx-pinyin x86_64 4.2.9.1-2.p03.ky10 @anaconda 7.1 M
fcitx-qt5-devel x86_64 1.2.4-3.1.ky10 @anaconda 57 k
ipmitool x86_64 1.8.18-15.ky10 @anaconda 1.4 M
kylin-activation x86_64 1.3.10-5.p27.ky10 @anaconda 553 k
python2-mysqlclient x86_64 1.3.12-8.ky10 @anaconda 349 k
rsyslog-relp x86_64 8.2006.0-7.p01.ky10 @anaconda 62 k
security-tool x86_64 2.0-1.75.p01.ky10 @anaconda 45 k
Removing unused dependencies:
assimp x86_64 3.3.1-19.ky10 @anaconda 7.1 M
fcitx x86_64 4.2.9.1-2.p03.ky10 @anaconda 1.0 M
fcitx-data noarch 4.2.9.1-2.p03.ky10 @anaconda 5.3 M
fcitx-gtk2 x86_64 4.2.9.1-2.p03.ky10 @anaconda 34 k
fcitx-gtk3 x86_64 4.2.9.1-2.p03.ky10 @anaconda 34 k
fcitx-libs x86_64 4.2.9.1-2.p03.ky10 @anaconda 1.6 M
fcitx-qt5 x86_64 1.2.4-3.1.ky10 @anaconda 626 k
firebird x86_64 3.0.3.32900-9.p02.ky10 @anaconda 18 M
freetds x86_64 1.00.38-8.ky10 @anaconda 2.6 M
gsm x86_64 1.0.18-4.ky10 @anaconda 95 k
gstreamer1-plugins-bad-free x86_64 1.16.2-2.ky10 @anaconda 5.7 M
ipmitool-help noarch 1.8.18-15.ky10 @anaconda 92 k
irrlicht x86_64 1.8.4-11.ky10 @anaconda 5.3 M
kf5-filesystem x86_64 5.59.0-1.1.ky10 @anaconda 0
kf5-kwindowsystem x86_64 5.55.0-1.p01.ky10 @anaconda 488 k
libaesgm x86_64 20090429-21.ky10 @anaconda 118 k
libchewing x86_64 0.5.1-17.ky10 @anaconda 3.7 M
libestr x86_64 0.1.11-1.ky10 @anaconda 43 k
libfastjson x86_64 0.99.9-1.ky10 @anaconda 72 k
libmng x86_64 2.0.3-10.ky10 @anaconda 633 k
libnet x86_64 1.2-1.ky10 @anaconda 98 k
libnice x86_64 0.1.14-10.ky10 @anaconda 455 k
librelp x86_64 1.2.16-3.ky10 @anaconda 157 k
libtommath x86_64 1.0.1-5.ky10 @anaconda 76 k
minizip x86_64 1.2.11-18.ky10 @anaconda 49 k
net-snmp x86_64 1:5.9-4.p01.ky10 @anaconda 4.8 M
net-snmp-help noarch 1:5.9-4.p01.ky10 @anaconda 904 k
perl-DBD-MySQL x86_64 4.046-6.ky10 @anaconda 333 k
poly2tri x86_64 0.0-19.ky10 @anaconda 54 k
postgresql-libs x86_64 10.5-22.ky10 @anaconda 897 k
qt x86_64 1:4.8.7-47.p04.ky10 @anaconda 351 M
qt5 noarch 5.14.2-1.ky10 @anaconda 19
qt5-qdbusviewer x86_64 5.11.1-5.p03.ky10 @anaconda 137 k
qt5-qt3d x86_64 5.11.1-4.ky10 @anaconda 7.3 M
qt5-qtbase-mysql x86_64 5.11.1-13.p01.ky10 @anaconda 79 k
qt5-qtbase-postgresql x86_64 5.11.1-13.p01.ky10 @anaconda 87 k
qt5-qtconnectivity x86_64 5.11.1-4.ky10 @anaconda 1.6 M
qt5-qtdoc noarch 5.11.1-4.ky10 @anaconda 8.0 M
qt5-qtgraphicaleffects x86_64 5.11.1-5.p01.ky10 @anaconda 645 k
qt5-qtimageformats x86_64 5.11.1-6.p01.ky10 @anaconda 374 k
qt5-qtlocation x86_64 5.11.1-6.ky10 @anaconda 10 M
qt5-qtmultimedia x86_64 5.11.1-6.ky10 @anaconda 2.8 M
qt5-qtquickcontrols x86_64 5.11.1-5.ky10 @anaconda 4.7 M
qt5-qtquickcontrols2 x86_64 5.11.1-4.ky10 @anaconda 6.8 M
qt5-qtscript x86_64 5.11.1-5.ky10 @anaconda 3.3 M
qt5-qtsensors x86_64 5.11.1-6.ky10 @anaconda 1.7 M
qt5-qtserialport x86_64 5.11.1-5.p01.ky10 @anaconda 216 k
qt5-qtwayland x86_64 5.11.1-6.ky10 @anaconda 3.3 M
qt5-qtwebchannel x86_64 5.11.1-5.ky10 @anaconda 261 k
qt5-qtwebsockets x86_64 5.11.1-6.ky10 @anaconda 274 k
rsyslog x86_64 8.2006.0-7.p01.ky10 @anaconda 2.6 M
unixODBC x86_64 2.3.7-3.ky10 @anaconda 1.3 M
Transaction Summary
======================================================================================================================================================================================
Remove 66 Packages
Freed space: 609 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: fcitx-configtool-0.4.10-6.p01.ky10.x86_64 1/1
Erasing : fcitx-configtool-0.4.10-6.p01.ky10.x86_64 1/66
Erasing : mariadb-3:10.3.9-12.p01.ky10.x86_64 2/66
Running scriptlet: mariadb-server-3:10.3.9-12.p01.ky10.x86_64 3/66
Erasing : mariadb-server-3:10.3.9-12.p01.ky10.x86_64 3/66
Running scriptlet: mariadb-server-3:10.3.9-12.p01.ky10.x86_64 3/66
Erasing : fcitx-pinyin-4.2.9.1-2.p03.ky10.x86_64 4/66
Erasing : fcitx-chewing-0.2.3-8.ky10.x86_64 5/66
Erasing : mariadb-errmessage-3:10.3.9-12.p01.ky10.x86_64 6/66
Running scriptlet: security-tool-2.0-1.75.p01.ky10.x86_64 7/66
Erasing : security-tool-2.0-1.75.p01.ky10.x86_64 7/66
warning: /etc/kylin_security/security saved as /etc/kylin_security/security.rpmsave
Running scriptlet: security-tool-2.0-1.75.p01.ky10.x86_64 7/66
Erasing : fcitx-qt5-devel-1.2.4-3.1.ky10.x86_64 8/66
Erasing : fcitx-4.2.9.1-2.p03.ky10.x86_64 9/66
Running scriptlet: fcitx-4.2.9.1-2.p03.ky10.x86_64 9/66
Erasing : fcitx-qt5-1.2.4-3.1.ky10.x86_64 10/66
Erasing : fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64 11/66
Running scriptlet: fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64 11/66
/var/tmp/rpm-tmp.yjxvOw: line 1: /usr/bin/update-gtk-immodules: No such file or directory
Erasing : fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 12/66
Running scriptlet: fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 12/66
Erasing : fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 13/66
Running scriptlet: fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 13/66
Erasing : qt-1:4.8.7-47.p04.ky10.x86_64 14/66
Running scriptlet: qt-1:4.8.7-47.p04.ky10.x86_64 14/66
Erasing : freetds-1.00.38-8.ky10.x86_64 15/66
Running scriptlet: freetds-1.00.38-8.ky10.x86_64 15/66
Erasing : perl-DBD-MySQL-4.046-6.ky10.x86_64 16/66
Erasing : rsyslog-relp-8.2006.0-7.p01.ky10.x86_64 17/66
Running scriptlet: rsyslog-8.2006.0-7.p01.ky10.x86_64 18/66
Removed /etc/systemd/system/multi-user.target.wants/rsyslog.service.
Erasing : rsyslog-8.2006.0-7.p01.ky10.x86_64 18/66
Running scriptlet: rsyslog-8.2006.0-7.p01.ky10.x86_64 18/66
Erasing : python2-mysqlclient-1.3.12-8.ky10.x86_64 19/66
Erasing : kylin-activation-1.3.10-5.p27.ky10.x86_64 20/66
Erasing : qt5-5.14.2-1.ky10.noarch 21/66
Erasing : qt5-qt3d-5.11.1-4.ky10.x86_64 22/66
Running scriptlet: qt5-qt3d-5.11.1-4.ky10.x86_64 22/66
Erasing : assimp-3.3.1-19.ky10.x86_64 23/66
Running scriptlet: assimp-3.3.1-19.ky10.x86_64 23/66
Erasing : qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 24/66
Running scriptlet: ipmitool-1.8.18-15.ky10.x86_64 25/66
Erasing : ipmitool-1.8.18-15.ky10.x86_64 25/66
Running scriptlet: ipmitool-1.8.18-15.ky10.x86_64 25/66
Erasing : ipmitool-help-1.8.18-15.ky10.noarch 26/66
Erasing : qt5-qtdoc-5.11.1-4.ky10.noarch 27/66
Erasing : fcitx-data-4.2.9.1-2.p03.ky10.noarch 28/66
Running scriptlet: fcitx-data-4.2.9.1-2.p03.ky10.noarch 28/66
Erasing : mariadb-common-3:10.3.9-12.p01.ky10.x86_64 29/66
Running scriptlet: net-snmp-1:5.9-4.p01.ky10.x86_64 30/66
Erasing : net-snmp-1:5.9-4.p01.ky10.x86_64 30/66
Running scriptlet: net-snmp-1:5.9-4.p01.ky10.x86_64 30/66
Erasing : irrlicht-1.8.4-11.ky10.x86_64 31/66
Running scriptlet: irrlicht-1.8.4-11.ky10.x86_64 31/66
Erasing : qt5-qtimageformats-5.11.1-6.p01.ky10.x86_64 32/66
Erasing : qt5-qtbase-postgresql-5.11.1-13.p01.ky10.x86_64 33/66
Erasing : qt5-qtmultimedia-5.11.1-6.ky10.x86_64 34/66
Running scriptlet: qt5-qtmultimedia-5.11.1-6.ky10.x86_64 34/66
Erasing : gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64 35/66
Running scriptlet: gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64 35/66
Erasing : qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 36/66
Running scriptlet: qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 36/66
Erasing : kf5-kwindowsystem-5.55.0-1.p01.ky10.x86_64 37/66
Running scriptlet: firebird-3.0.3.32900-9.p02.ky10.x86_64 38/66
Erasing : firebird-3.0.3.32900-9.p02.ky10.x86_64 38/66
Running scriptlet: firebird-3.0.3.32900-9.p02.ky10.x86_64 38/66
Erasing : kf5-filesystem-5.59.0-1.1.ky10.x86_64 39/66
Erasing : net-snmp-help-1:5.9-4.p01.ky10.noarch 40/66
Erasing : libtommath-1.0.1-5.ky10.x86_64 41/66
Erasing : qt5-qtgraphicaleffects-5.11.1-5.p01.ky10.x86_64 42/66
Erasing : gsm-1.0.18-4.ky10.x86_64 43/66
Erasing : libnice-0.1.14-10.ky10.x86_64 44/66
Running scriptlet: libnice-0.1.14-10.ky10.x86_64 44/66
Erasing : postgresql-libs-10.5-22.ky10.x86_64 45/66
Running scriptlet: postgresql-libs-10.5-22.ky10.x86_64 45/66
Erasing : libmng-2.0.3-10.ky10.x86_64 46/66
Running scriptlet: libmng-2.0.3-10.ky10.x86_64 46/66
Erasing : libaesgm-20090429-21.ky10.x86_64 47/66
Running scriptlet: libaesgm-20090429-21.ky10.x86_64 47/66
Erasing : mariadb-connector-c-3.0.6-8.ky10.x86_64 48/66
Erasing : minizip-1.2.11-18.ky10.x86_64 49/66
Erasing : poly2tri-0.0-19.ky10.x86_64 50/66
Erasing : qt5-qdbusviewer-5.11.1-5.p03.ky10.x86_64 51/66
Erasing : qt5-qtconnectivity-5.11.1-4.ky10.x86_64 52/66
Erasing : qt5-qtlocation-5.11.1-6.ky10.x86_64 53/66
Running scriptlet: qt5-qtlocation-5.11.1-6.ky10.x86_64 53/66
Erasing : qt5-qtquickcontrols-5.11.1-5.ky10.x86_64 54/66
Erasing : qt5-qtscript-5.11.1-5.ky10.x86_64 55/66
Erasing : qt5-qtsensors-5.11.1-6.ky10.x86_64 56/66
Erasing : qt5-qtserialport-5.11.1-5.p01.ky10.x86_64 57/66
Erasing : qt5-qtwayland-5.11.1-6.ky10.x86_64 58/66
Erasing : qt5-qtwebchannel-5.11.1-5.ky10.x86_64 59/66
Erasing : qt5-qtwebsockets-5.11.1-6.ky10.x86_64 60/66
Erasing : libestr-0.1.11-1.ky10.x86_64 61/66
Running scriptlet: libestr-0.1.11-1.ky10.x86_64 61/66
Erasing : libfastjson-0.99.9-1.ky10.x86_64 62/66
Running scriptlet: libfastjson-0.99.9-1.ky10.x86_64 62/66
Erasing : libnet-1.2-1.ky10.x86_64 63/66
Running scriptlet: libnet-1.2-1.ky10.x86_64 63/66
Erasing : librelp-1.2.16-3.ky10.x86_64 64/66
Running scriptlet: librelp-1.2.16-3.ky10.x86_64 64/66
Erasing : unixODBC-2.3.7-3.ky10.x86_64 65/66
Running scriptlet: unixODBC-2.3.7-3.ky10.x86_64 65/66
Erasing : libchewing-0.5.1-17.ky10.x86_64 66/66
Running scriptlet: libchewing-0.5.1-17.ky10.x86_64 66/66
Verifying : assimp-3.3.1-19.ky10.x86_64 1/66
Verifying : fcitx-4.2.9.1-2.p03.ky10.x86_64 2/66
Verifying : fcitx-chewing-0.2.3-8.ky10.x86_64 3/66
Verifying : fcitx-configtool-0.4.10-6.p01.ky10.x86_64 4/66
Verifying : fcitx-data-4.2.9.1-2.p03.ky10.noarch 5/66
Verifying : fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64 6/66
Verifying : fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 7/66
Verifying : fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 8/66
Verifying : fcitx-pinyin-4.2.9.1-2.p03.ky10.x86_64 9/66
Verifying : fcitx-qt5-1.2.4-3.1.ky10.x86_64 10/66
Verifying : fcitx-qt5-devel-1.2.4-3.1.ky10.x86_64 11/66
Verifying : firebird-3.0.3.32900-9.p02.ky10.x86_64 12/66
Verifying : freetds-1.00.38-8.ky10.x86_64 13/66
Verifying : gsm-1.0.18-4.ky10.x86_64 14/66
Verifying : gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64 15/66
Verifying : ipmitool-1.8.18-15.ky10.x86_64 16/66
Verifying : ipmitool-help-1.8.18-15.ky10.noarch 17/66
Verifying : irrlicht-1.8.4-11.ky10.x86_64 18/66
Verifying : kf5-filesystem-5.59.0-1.1.ky10.x86_64 19/66
Verifying : kf5-kwindowsystem-5.55.0-1.p01.ky10.x86_64 20/66
Verifying : kylin-activation-1.3.10-5.p27.ky10.x86_64 21/66
Verifying : libaesgm-20090429-21.ky10.x86_64 22/66
Verifying : libchewing-0.5.1-17.ky10.x86_64 23/66
Verifying : libestr-0.1.11-1.ky10.x86_64 24/66
Verifying : libfastjson-0.99.9-1.ky10.x86_64 25/66
Verifying : libmng-2.0.3-10.ky10.x86_64 26/66
Verifying : libnet-1.2-1.ky10.x86_64 27/66
Verifying : libnice-0.1.14-10.ky10.x86_64 28/66
Verifying : librelp-1.2.16-3.ky10.x86_64 29/66
Verifying : libtommath-1.0.1-5.ky10.x86_64 30/66
Verifying : mariadb-3:10.3.9-12.p01.ky10.x86_64 31/66
Verifying : mariadb-common-3:10.3.9-12.p01.ky10.x86_64 32/66
Verifying : mariadb-connector-c-3.0.6-8.ky10.x86_64 33/66
Verifying : mariadb-errmessage-3:10.3.9-12.p01.ky10.x86_64 34/66
Verifying : mariadb-server-3:10.3.9-12.p01.ky10.x86_64 35/66
Verifying : minizip-1.2.11-18.ky10.x86_64 36/66
Verifying : net-snmp-1:5.9-4.p01.ky10.x86_64 37/66
Verifying : net-snmp-help-1:5.9-4.p01.ky10.noarch 38/66
Verifying : perl-DBD-MySQL-4.046-6.ky10.x86_64 39/66
Verifying : poly2tri-0.0-19.ky10.x86_64 40/66
Verifying : postgresql-libs-10.5-22.ky10.x86_64 41/66
Verifying : python2-mysqlclient-1.3.12-8.ky10.x86_64 42/66
Verifying : qt-1:4.8.7-47.p04.ky10.x86_64 43/66
Verifying : qt5-5.14.2-1.ky10.noarch 44/66
Verifying : qt5-qdbusviewer-5.11.1-5.p03.ky10.x86_64 45/66
Verifying : qt5-qt3d-5.11.1-4.ky10.x86_64 46/66
Verifying : qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 47/66
Verifying : qt5-qtbase-postgresql-5.11.1-13.p01.ky10.x86_64 48/66
Verifying : qt5-qtconnectivity-5.11.1-4.ky10.x86_64 49/66
Verifying : qt5-qtdoc-5.11.1-4.ky10.noarch 50/66
Verifying : qt5-qtgraphicaleffects-5.11.1-5.p01.ky10.x86_64 51/66
Verifying : qt5-qtimageformats-5.11.1-6.p01.ky10.x86_64 52/66
Verifying : qt5-qtlocation-5.11.1-6.ky10.x86_64 53/66
Verifying : qt5-qtmultimedia-5.11.1-6.ky10.x86_64 54/66
Verifying : qt5-qtquickcontrols-5.11.1-5.ky10.x86_64 55/66
Verifying : qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 56/66
Verifying : qt5-qtscript-5.11.1-5.ky10.x86_64 57/66
Verifying : qt5-qtsensors-5.11.1-6.ky10.x86_64 58/66
Verifying : qt5-qtserialport-5.11.1-5.p01.ky10.x86_64 59/66
Verifying : qt5-qtwayland-5.11.1-6.ky10.x86_64 60/66
Verifying : qt5-qtwebchannel-5.11.1-5.ky10.x86_64 61/66
Verifying : qt5-qtwebsockets-5.11.1-6.ky10.x86_64 62/66
Verifying : rsyslog-8.2006.0-7.p01.ky10.x86_64 63/66
Verifying : rsyslog-relp-8.2006.0-7.p01.ky10.x86_64 64/66
Verifying : security-tool-2.0-1.75.p01.ky10.x86_64 65/66
Verifying : unixODBC-2.3.7-3.ky10.x86_64 66/66
Removed:
assimp-3.3.1-19.ky10.x86_64 fcitx-4.2.9.1-2.p03.ky10.x86_64 fcitx-chewing-0.2.3-8.ky10.x86_64
fcitx-configtool-0.4.10-6.p01.ky10.x86_64 fcitx-data-4.2.9.1-2.p03.ky10.noarch fcitx-gtk2-4.2.9.1-2.p03.ky10.x86_64
fcitx-gtk3-4.2.9.1-2.p03.ky10.x86_64 fcitx-libs-4.2.9.1-2.p03.ky10.x86_64 fcitx-pinyin-4.2.9.1-2.p03.ky10.x86_64
fcitx-qt5-1.2.4-3.1.ky10.x86_64 fcitx-qt5-devel-1.2.4-3.1.ky10.x86_64 firebird-3.0.3.32900-9.p02.ky10.x86_64
freetds-1.00.38-8.ky10.x86_64 gsm-1.0.18-4.ky10.x86_64 gstreamer1-plugins-bad-free-1.16.2-2.ky10.x86_64
ipmitool-1.8.18-15.ky10.x86_64 ipmitool-help-1.8.18-15.ky10.noarch irrlicht-1.8.4-11.ky10.x86_64
kf5-filesystem-5.59.0-1.1.ky10.x86_64 kf5-kwindowsystem-5.55.0-1.p01.ky10.x86_64 kylin-activation-1.3.10-5.p27.ky10.x86_64
libaesgm-20090429-21.ky10.x86_64 libchewing-0.5.1-17.ky10.x86_64 libestr-0.1.11-1.ky10.x86_64
libfastjson-0.99.9-1.ky10.x86_64 libmng-2.0.3-10.ky10.x86_64 libnet-1.2-1.ky10.x86_64
libnice-0.1.14-10.ky10.x86_64 librelp-1.2.16-3.ky10.x86_64 libtommath-1.0.1-5.ky10.x86_64
mariadb-3:10.3.9-12.p01.ky10.x86_64 mariadb-common-3:10.3.9-12.p01.ky10.x86_64 mariadb-connector-c-3.0.6-8.ky10.x86_64
mariadb-errmessage-3:10.3.9-12.p01.ky10.x86_64 mariadb-server-3:10.3.9-12.p01.ky10.x86_64 minizip-1.2.11-18.ky10.x86_64
net-snmp-1:5.9-4.p01.ky10.x86_64 net-snmp-help-1:5.9-4.p01.ky10.noarch perl-DBD-MySQL-4.046-6.ky10.x86_64
poly2tri-0.0-19.ky10.x86_64 postgresql-libs-10.5-22.ky10.x86_64 python2-mysqlclient-1.3.12-8.ky10.x86_64
qt-1:4.8.7-47.p04.ky10.x86_64 qt5-5.14.2-1.ky10.noarch qt5-qdbusviewer-5.11.1-5.p03.ky10.x86_64
qt5-qt3d-5.11.1-4.ky10.x86_64 qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 qt5-qtbase-postgresql-5.11.1-13.p01.ky10.x86_64
qt5-qtconnectivity-5.11.1-4.ky10.x86_64 qt5-qtdoc-5.11.1-4.ky10.noarch qt5-qtgraphicaleffects-5.11.1-5.p01.ky10.x86_64
qt5-qtimageformats-5.11.1-6.p01.ky10.x86_64 qt5-qtlocation-5.11.1-6.ky10.x86_64 qt5-qtmultimedia-5.11.1-6.ky10.x86_64
qt5-qtquickcontrols-5.11.1-5.ky10.x86_64 qt5-qtquickcontrols2-5.11.1-4.ky10.x86_64 qt5-qtscript-5.11.1-5.ky10.x86_64
qt5-qtsensors-5.11.1-6.ky10.x86_64 qt5-qtserialport-5.11.1-5.p01.ky10.x86_64 qt5-qtwayland-5.11.1-6.ky10.x86_64
qt5-qtwebchannel-5.11.1-5.ky10.x86_64 qt5-qtwebsockets-5.11.1-6.ky10.x86_64 rsyslog-8.2006.0-7.p01.ky10.x86_64
rsyslog-relp-8.2006.0-7.p01.ky10.x86_64 security-tool-2.0-1.75.p01.ky10.x86_64 unixODBC-2.3.7-3.ky10.x86_64
Complete!
[root@localhost ~]#
验证卸载Mariadb成功
yum list --installed mariadb*
rpm -qa|grep -i mariadb*
查看Mariadb配置文件和目录是否还存在 已经不存在了
ls -l /etc/my.cnf
ls -l /etc/my.cnf.d
至此mariadb卸载完成
3.2.1.2、下载Mysql安装包
访问官网下载链接 链接: https://dev.mysql.com/downloads/mysql/
选择如下 点击下载按钮 下载安装包
选择 mysql-8.0.35-1.el8.x86_64.rpm-bundle.tar 点击下载
为什么选择redhat 8的操作系统版本呢?
https://www.kylinos.cn/about/news/814.html
通过查询麒麟官网得知,银河麒麟高级服务器操作系统是兼容centos8的,centos8和redhat8兼容。
3.2.1.3、安装Mysql 8.35
官方安装文档
链接: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/linux-installation-rpm.html
RPM Packages for MySQL Community Edition
Package Name | Summary |
---|---|
mysql-community-client | MySQL client applications and tools |
mysql-community-client-plugins | Shared plugins for MySQL client applications |
mysql-community-common | Common files for server and client libraries |
mysql-community-devel | Development header files and libraries for MySQL database client applications |
mysql-community-embedded-compat | MySQL server as an embedded library with compatibility for applications using version 18 of the library |
mysql-community-icu-data-files | MySQL packaging of ICU data files needed by MySQL regular expressions |
mysql-community-libs | Shared libraries for MySQL database client applications |
mysql-community-libs-compat | Shared compatibility libraries for previous MySQL installations; only present if previous MySQL versions are supported by the platform |
mysql-community-server | Database server and related tools |
mysql-community-server-debug | Debug server and plugin binaries |
mysql-community-test | Test suite for the MySQL server |
mysql-community | The source code RPM looks similar to mysql-community-8.0.35-1.el7.src.rpm, depending on selected OS |
Additional debuginfo RPMs | There are several debuginfo packages: mysql-community-client-debuginfo, mysql-community-libs-debuginfo mysql-community-server-debug-debuginfo mysql-community-server-debuginfo, and mysql-community-test-debuginfo. |
rpm包的名称格式:packagename-version-distribution-arch.rpm
安装步骤如下
创建Mysql安装包目录
mkdir -p /root/package/mysql
上传Mysql安装包mysql-8.0.35-1.el8.x86_64.rpm-bundle.tar 到/root/package/mysql 目录下
cd /root/package/mysql
mkdir mysql-8.0.35-1.el8.x86_64.rpm-bundle
tar -xvf mysql-8.0.35-1.el8.x86_64.rpm-bundle.tar -C mysql-8.0.35-1.el8.x86_64.rpm-bundle/
cd mysql-8.0.35-1.el8.x86_64.rpm-bundle/
只需要安装以下软件包即可
In most cases, you need to install the mysql-community-server, mysql-community-client, mysql-community-client-plugins, mysql-community-libs, mysql-community-icu-data-files, mysql-community-common, and mysql-community-libs-compat packages to get a functional, standard MySQL installation. To perform such a standard, basic installation, go to the folder that contains all those packages (and, preferably, no other RPM packages with similar names), and issue the following command:
意思是说这个软件包目录下只包含有上面提到的这几个包即可,不能有其他的包,因此把其他的包删除掉。只保留
mysql-community-server, mysql-community-client, mysql-community-client-plugins, mysql-community-libs, mysql-community-icu-data-files, mysql-community-common, and mysql-community-libs-compat
rm -f mysql-community-server-debug*
rm -f mysql-community-debug*
rm -f mysql-community-client-debuginfo-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-test-*
rm -f mysql-community-client-plugins-debuginfo-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-devel-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-libs-debuginfo-8.0.35-1.el8.x86_64.rpm
安装mysql前,操作系统上没有默认的mysql根目录/var/lib/mysql、mysql配置文件/etc/my.cnf
yum install mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-*
安装完成如图所示
查看安装的mysql包
yum list --installed |grep -i mysql
rpm -qa|grep -i mysql
安装完成后,会形成以下文件和目录(执行安装命令后才会形成以下文件和目录)
安装mysql后为什么就会形成以下文件和目录呢?
这是因为所谓的安装mysql,安装mysql这个动作所做的操作是:把mysql安装包中的文件目录结构复制到安装mysql的操作系统上,仅此而已。mysql安装包里面本就有以下这些文件和目录。
Files or Resources | Location |
---|---|
Files or Resources | Location |
Client programs and scripts | /usr/bin |
mysqld server | /usr/sbin |
Configuration file | /etc/my.cnf |
Data directory | /var/lib/mysql |
Error log file | For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log |
Value of secure_file_priv | /var/lib/mysql-files |
System V init script | For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld |
Systemd service | For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld |
Pid file | /var/run/mysqld/mysqld.pid |
Socket | /var/lib/mysql/mysql.sock |
Keyring directory | /var/lib/mysql-keyring |
Unix manual pages | /usr/share/man |
Include (header) files | /usr/include/mysql |
Libraries | /usr/lib64/mysql |
Miscellaneous support files (for example, error messages, and character set files) | /usr/share/mysql |
安装完后 也会产生一个名为mysql 的系统用户,和一个名为mysql 的系统用户组。
至此安装Mysql 8.35完成。
如果在安装过程中出现问题,您可能会在错误日志文件/var/log/mysqld.log中找到日志信息。
安装成功的情况下 /var/log/mysqld.log是空的
如果需要切换到Mysql用户 使用如下命令
su - mysql --shell=/bin/bash
下面这项是可选的 看调试信息才需要这样启动Mysql,一般不需要。
Debug Package. A special variant of MySQL Server compiled with the debug package has been included in the server RPM packages. It performs debugging and memory allocation checks and produces a trace file when the server is running. To use that debug version, start MySQL with /usr/sbin/mysqld-debug, instead of starting it as a service or with /usr/sbin/mysqld. See The DBUG Package for the debug options you can use.
查看安装mysql后形成的目录和文件以及默认的配置文件
1、Client programs and scripts
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/bin目录下的东西
和mysql安装包mysql-community-client-8.0.35-1.el8.x86_64.rpm里面的/usr/bin目录下的东西
2、mysqld server
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的东西
3、Configuration file
安装mysql后为什么就会创建mysql的配置文件/etc/my.cnf呢?
这是因为mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm,这个包里面的目录结构如下
所谓的安装mysql,安装mysql这个动作所做的操作是:把mysql安装包中的文件目录结构复制到安装mysql的操作系统上,仅此而已。
4、Data directory
安装mysql后,mysql根目录/var/lib/msyql里面是空的。说明此时还没有初始化mysql,仅仅是安装完成了mysql而已。
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql文件夹
5、Error log file
/var/log/mysqld.log不是从mysql安装包拷贝的,是安装mysql时在操作系统上新建的这个文件,看这个文件的日期就是安装mysql的日期,和其他文件夹比如mysql根目录/var/lib/mysql、/var/lib/mysql-files的日期是不一样的。
6、Value of secure_file_priv
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql-files文件夹
7、System V init script
安装包里没有这个文件夹,也可能因为此次安装Mysql使用的是银河麒麟高级服务器操作系统v10 sp3,属于systemd系列的操作系统,所以并没有创建system v的启动脚本吧。不深究了,不影响。
8、Systemd service
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/usrl/ib/systemd/system文件夹下的mysqld.service文件。
9、Pid file
mysql还没有启动,所以没有mysql的pid文件。
10、Socket
mysql还没有启动,所以没有mysql的socket文件。
11、Keyring directory
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql-keyring文件夹
12、Unix manual pages
/usr/share/man
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/share/man目录下的东西
对应mysql安装包mysql-community-client-8.0.35-1.el8.x86_64.rpm里面的/usr/shar/man文件夹
13、Include (header) files
14、Libraries
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/lib64目录下的东西
15、Miscellaneous support files (for example, error messages, and character set files)、
3.2.1.4、启动mysql 8.0.35
对于使用rpm包或deb包安装mysql的,启动mysql时就会执行初始化。本文是用rpm包安装的mysql,因此启动mysql服务就会初始化mysql。
安装后默认不会启动Mysql服务
然后初始化mysql,使用rpm包或deb包安装mysql的,启动mysql时就会执行初始化。本文是用rpm包安装的mysql,因此启动mysql服务即可。
注意启动mysql服务前/var/lib/mysql下是空的
启动mysql命令
systemctl start mysqld.service
此启动mysql命令做下面这些事情
- 初始化mysql服务
检查有没有mysql根目录存在,如果没有mysql根目录存在,则创建mysql根目录。然后在mysql根目录下创建mysql的系统数据库:默认的系统数据库:mysql、sys、performance_schema、information_schema。 - 产生ssl证书和密钥在Mysql根目录下
- validate_password默认安装。validate_password实现的默认密码策略要求密码至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,并且密码总长度至少为8个字符。
- 已创建超级用户帐户“root”@“localhost”。超级用户的密码已设置并存储在错误日志文件中。查看mysql的root账户默认密码
grep 'temporary password' /var/log/mysqld.log
1、查看数据目录
启动mysql服务前/var/lib/mysql下是空的
启动mysql服务后/var/lib/mysql 文件夹的大小是192M。(里面包含了初始化mysql时形成的mysql系统数据库以及密钥文件等)
2、证书在数据目录下
3、查看 超级用户帐户“root”@“localhost” 的默认密码 9lE,%p=rlZz2
grep 'temporary password' /var/log/mysqld.log
4、启动Mysql后 会形成sock文件和pid文件
ls -lh /var/lib/mysql/mysql.sock
ls -lh /var/run/mysqld/mysqld.pid
cat /var/run/mysqld/mysqld.pid
安装mysql后默认是监听在“:::3306”上的,这个表示ipv6监听,同时也包含了ipv4,也就说,ipv6和ipv4都支持访问mysql。
停止mysql服务后 sock文件和pid文件都消失了
ls -lh /var/lib/mysql/mysql.sock
ls -lh /var/run/mysqld/mysqld.pid
cat /var/run/mysqld/mysqld.pid
开启mysql服务后 sock文件和pid文件重新生成了 只不过pid文件的数值不同了。
ls -lh /var/lib/mysql/mysql.sock
ls -lh /var/run/mysqld/mysqld.pid
cat /var/run/mysqld/mysqld.pid
5、查看启动日志
下面是第一次启动mysql服务的日志 含有初始化日志:[System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 10985
初始化后停止mysql服务,再次开启mysql服务就不会有初始化日志了,只会有启动日志。
3.2.1.5、安装后配置
链接: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/postinstallation.html
使用安装Mysql数据库 时生成的默认密码登录mysql数据库
mysql -uroot -p
没修改默认密码前不能进行数据库sql操作
show databases;
修改Mysql默认密码为Mysql@123
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql@123' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> use mysql;
Database changed
mysql>
mysql> update user set host = "%" where user = "root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql@123';
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
修改密码后即可成功执行数据库sql命令
使用新密码登录mysql数据库
3.2.2、默认根目录安装mysql后,创建mysql数据表一段时间后发现mysql根目录空间不够、需要迁移根目录
3.2.2.1、创建mysql数据
下面创建mysql数据表,为了快速创建,直接从其他数据库中备份的sql文件恢复到mysql容器中。
创建mysql数据表前查看mysql根目录占用空间 占用了192M,因此mysql服务根目录一定要大,或者能够动态扩容才行,不然很快就会因为mysql数据表占用空间增大导致mysql根目录增大,最终导致mysql根目录所在宿主机的分区爆满、最终操作系统崩溃。
查看mysq配置文件/etc/my.cnf发现mysql根目录是/var/lib/mysql
cat /etc/my.cnf|grep -i dir
直接从其他数据库中备份的sql文件恢复到mysql中
source /root/8.0.24AllDatabasesBackup.sql;
恢复mysql数据完成
恢复mysql数据后,再次查看mysql数据库如下
show databases;
use kgc;
select table_name,table_comment,create_time from information_schema.TABLES where table_schema='kgc';
select * from banji;
恢复mysql数据完成后再次查看mysql根目录占用空间,占用从192M增加到了336M。这是因为恢复的数据库表占用了空间。
恢复mysql数据前查看mysql根目录占用空间,是192M。
很快随着mysql数据量增多,就会导致mysql根目录的增大,最终导致mysql根目录所在的分区磁盘占用爆满,操作系统崩溃。怎么解决这个问题呢?只需迁移mysql根目录到一个比较大的分区即可或者迁移mysql根目录到一个可以动态扩展的分区,通常二者都要,把mysql根目录迁移到一个空间比较大的而且可以动态扩容的分区即可。
3.2.3、配置新的mysql根目录、迁移mysql根目录数据到新的根目录
停止mysql服务
systemctl stop mysqld.service
建立新的mysql根目录,执行命令df -h,找一个大的磁盘。这里指定的mysql新的根目录是/home/mysql
mkdir -p /home/mysql
迁移/var/lib/mysql目录下面的文件到 新的mysql根目录/home/mysql
rm -rf /home/mysql
cp -r /var/lib/mysql /home/mysql
更改迁移后mysql根目录属主为mysql:mysql,因为cp -r /var/lib/mysql /home/mysql之后,/home/mysql的属主是root:root。
chown -R mysql:mysql /home/mysql/
编辑mysql配置文件/etc/my.cnf 指定mysql根目录是/home/mysql
cp /etc/my.cnf /etc/my.cnf.bak
vi /etc/my.cnf
修改datadir和socket参数
修改前
修改后
然后启动mysql服务
systemctl start mysqld.service
检查mysql新的根目录是否配置成功
查看mysql启动日志 可以看到启动日志中的mysql socket文件是 /home/mysql/mysql.sock 说明mysql已经使用了新的mysql配置。
cat /var/log/mysqld.log
启动mysql服务成功后,确认迁移mysql根目录之前的数据库数据还在不
mysql -uroot -p
报错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
配置文件已经指定了socket=/home/mysql/mysql.sock 不知道为什么mysql还是去找默认的socket文件/var/lib/mysql/mysql.sock
socket=/home/mysql/mysql.sock
在登录mysql时使用-S参数手动指定正确的socket文件即可
mysql -uroot -p -S /home/mysql/mysql.sock
这个问题可以通过 创建一个软连接文件名为/var/lib/mysql/mysql.sock 连接到 迁移目录后新的mysql.sock文件,这样之后登录mysql时就不用添加-S参数了。
ln -s /home/mysql/mysql.sock /var/lib/mysql/mysql.sock
迁移mysql根目录后,再次查看mysql数据库如下,确认和迁移根目录前的mysql数据库数据是否一致
show databases;
use kgc;
select table_name,table_comment,create_time from information_schema.TABLES where table_schema='kgc';
select * from banji;
3.2.4、重要!迁移mysql根目录后 确认mysql服务正常
3.2.4.1、迁移mysql根目录后,检查mysql启动日志是否正常
cat /var/log/mysqld.log
如下mysql启动日志无报错即为正常。
3.2.4.2、执行mysql服务检测,确认mysql服务的接口调用是否正常
进入mysql 查看数据库表和迁移mysql根目录之前是否一致
查询banji表的数据 和迁移mysql根目录之前的数据是一样的。说明mysql内部服务没问题。
3.2.4.3、创建新的数据库,确认迁移mysql根目录后 新的mysql根目录下是否会出现和这个数据库同名的文件夹
如果创建test数据库后,查看新的mysql根目录下有test文件夹,说明mysql正在使用新的根目录/home/mysql作为数据目录,说明迁移mysql根目录成功了。
创建test数据库前,查看新的mysql根目录下没有test文件夹
ls -l /home/mysql/test
创建test数据库
create database test default character set utf8mb4;
查看新的mysql根目录下有test文件夹,说明mysql正在使用新的根目录/home/mysql作为数据目录。
ls -l /home/mysql/test
以上确认均没问题,至此,本次mysql根目录迁移完成。