银河麒麟v10 rpm命令 手动安装mysql 8.35 手动初始化mysql数据库
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卸载完成
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、安装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
3.1、安装Mysql 8.35
创建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官网建议需要安装以上6个包,实际上运行起来mysql,这两个包也不需要:mysql-community-client-plugins-8.0.35-1.el8.x86_64.rpm、mysql-community-icu-data-files-8.0.35-1.el8.x86_64.rpm
删除这两个包
rm -f mysql-community-client-plugins-8.0.35-1.el8.x86_64.rpm
rm -f mysql-community-icu-data-files-8.0.35-1.el8.x86_64.rpm
安装mysql前,操作系统上没有没有默认的mysql根目录/var/lib/mysql、,mysql配置文件/etc/my.cnf
然后使用rpm命令安装这4个包
rpm -ivh mysql-community-common-8.0.35-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.35-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.35-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.35-1.el8.x86_64.rpm --nodeps --force
命令解析
----force :如果这个包已经存在,覆盖安装。忽略包之间的冲突。
–nodeps :忽略rpm包的依赖关系。就是说缺少依赖包也要安装。
安装完成如图所示
查看安装的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
ls -l /usr/bin/|grep mysql
对应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
ls -l /usr/sbin/|grep mysql
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的东西
3、Configuration file
ls -l /etc/my.cnf
安装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而已。
ls -l /var/lib/mysql
ls -lhd /var/lib/mysql
du -sh /var/lib/mysql
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql文件夹
5、Error log file
ls -l /var/log/mysqld.log
cat /var/log/mysqld.log
/var/log/mysqld.log为空说明安装mysql成功了。
/var/log/mysqld.log不是从mysql安装包拷贝的,是安装mysql时在操作系统上新建的这个文件,看这个文件的日期就是安装mysql的日期,和其他文件夹比如mysql根目录/var/lib/mysql、/var/lib/mysql-files的日期是不一样的。
6、Value of secure_file_priv
ls -l /var/lib/mysql-files/
ls -lhd /var/lib/mysql-files/
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql-files文件夹
7、System V init script
ls -lh /etc/init.d/mysqld
安装包里没有这个文件夹,也可能因为此次安装Mysql使用的是银河麒麟高级服务器操作系统v10 sp3,属于systemd系列的操作系统,所以并没有创建system v的启动脚本吧。不深究了,不影响。
8、Systemd service
systemctl status mysqld.service
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/usrl/ib/systemd/system文件夹下的mysqld.service文件。
9、Pid file
ls -l /var/run/mysqld/mysqld.pid
mysql还没有启动,所以没有mysql的pid文件。
10、Socket
ls -l /var/lib/mysql/mysql.sock
mysql还没有启动,所以没有mysql的socket文件。
11、Keyring directory
ls -l /var/lib/mysql-keyring/
ls -lhd /var/lib/mysql-keyring/
对应mysql安装包mysql-community-server-8.0.35-1.el8.x86_64.rpm里面的/usr/sbin目录下的/var/lib/mysql-keyring文件夹
12、Unix manual pages
ls -l /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
ls -ld /usr/lib64/mysql/
ls -l /usr/lib64/mysql/
对应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)
ls -l /usr/share/mysql-8.0/
对应mysql安装包mysql-community-common-8.0.35-1.el8.x86_64.rpm里面的/usr/share/mysql-8.0目录下的东西
3.2、初始化mysql 8.0.35
3.2.1、按照mysql默认配置文件初始化mysql 8.0.35
对于使用rpm包或deb包安装mysql的,启动mysql时就会执行初始化。本文是用rpm包通过rpm命令安装的mysql,因此启动mysql服务不会初始化mysql,需要在启动mysql服务前手动初始化msyql。
安装后默认不会启动Mysql服务,因为需要先手动初始化mysql 然后再启动mysql。
初始化mysql命令
mysqld --initialize --console
查看初始化日志
cat /var/log/mysqld.log
此初始化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 文件夹的大小是180M。(里面包含了初始化mysql时形成的mysql系统数据库以及密钥文件等)
ls -l /var/lib/mysql
du -sh /var/lib/mysql/
du -sh /var/lib/mysql/*
2、证书在数据目录下
ls -lh /var/lib/mysql
3、查看 超级用户帐户“root”@“localhost” 的默认密码 >8oy8Tg/uO;v
grep 'temporary password' /var/log/mysqld.log
3.2.2、修改mysql配置文件更换mysql根目录,然后再初始化mysql 8.0.35
对于使用rpm包或deb包安装mysql的,启动mysql时就会执行初始化。本文是用rpm包通过rpm命令安装的mysql,因此启动mysql服务不会初始化mysql,需要在启动mysql服务前手动初始化msyql。
安装后默认不会启动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,使
初始化mysql命令
mysqld --initialize --console
查看初始化日志
cat /var/log/mysqld.log
注意初始化mysql服务前/var/lib/mysql下是空的,并且没有/home/mysql文件夹
此启动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” 的默认密码 DaBRD0#r6Imr
grep 'temporary password' /var/log/mysqld.log
3.3、更改mysql根目录属主为mysql
3.3.1、按照mysql默认配置文件初始化mysql 8.0.35的
手动初始化mysql后,注意mysql根目录/var/lib/mysql下的文件和文件夹属主不是mysql
更改属主
chown -R mysql:mysql /var/lib/mysql
3.3.2、修改mysql配置文件更换mysql根目录,然后再初始化mysql 8.0.35的
手动初始化mysql后,注意mysql根目录/home/mysql下的文件和文件夹属主不是mysql
更改/home/mysql 属主为mysql:mysql
chown -R mysql:mysql /home/mysql
3.4、启动mysql 8.0.35
3.4.1、按照mysql默认配置文件初始化mysql 8.0.35的
启动mysql服务
systemctl start mysqld.service
查看启动日志得知已经启动成功
注:如果在手动初始化Mysql后,不更改/var/lib/mysql的属主为msyql:mysql,直接启动mysql的话,会启动失败查看mysql日志报mysql没有权限创建/var/lib/mysql/auto.cnf文件的错误。
cat /var/log/mysqld.log
启动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文件都消失了
开启mysql服务后 sock文件和pid文件重新生成了 只不过pid文件的数值不同了。
查看启动日志
cat /var/log/mysqld.log
下面是第一次启动mysql服务的日志 含有初始化日志:[System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 67305
初始化后停止mysql服务,再次开启mysql服务就不会有初始化日志了,只会有启动日志。
3.4.2、修改mysql配置文件更换mysql根目录,然后再初始化mysql 8.0.35的
启动mysql服务
systemctl start mysqld.service
查看mysql日志得知已经启动成功
cat /var/log/mysqld.log
注:如果在手动初始化Mysql后,不更改/var/lib/mysql的属主为msyql:mysql,直接启动mysql的话,会启动失败,查看mysql服务启动日志报错:[ERROR] [MY-013276] [Server] Failed to set datadir to ‘/home/mysql/’ (OS errno: 13 - Permission denied)
无法设置/home/mysql为mysql根目录。
查看报错:[Warning] [MY-010091] [Server] Can’t create test file /home/mysql/mysqld_tmp_file_case_insensitive_test. 得知是/home/mysql目录不允许mysql进程在其下创建mysqld_tmp_file_case_insensitive_test 文件。
分析猜测是/home/mysql的属主不是mysql,因此mysql没有mysql进程没有权限向/home/mysql创建文件,导致启动mysql失败。
这次启动mysql服务,mysql日志没有任何输出,因为没有启动成功就直接退出启动了,还没有来及向mysql日志文件中写日志。
cat /var/log/mysqld.log
启动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文件的数值不同了。
查看启动日志
cat /var/log/mysqld.log
下面是第一次启动mysql服务的日志 含有初始化日志:[System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 66179
初始化后停止mysql服务,再次开启mysql服务就不会有初始化日志了,只会有启动日志。
3.5、安装后配置
3.5.1、按照mysql默认配置文件初始化mysql 8.0.35的
链接: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/postinstallation.html
使用安装Mysql数据库 时生成的默认密码登录mysql数据库
mysql -uroot -p
没修改默认密码前不能进行数据库sql操作,报错:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改Mysql默认密码为Mysql@123
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql@123' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.01 sec)
mysql> update user set host = "%" where user = "root";
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql@123';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)
mysql>
使用新密码登录mysql数据库
3.5.2、修改mysql配置文件更换mysql根目录,然后再初始化mysql 8.0.35的
链接: 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
然后使用安装Mysql数据库 时生成的默认密码登录mysql数据库
mysql -uroot -p
没修改默认密码前不能进行数据库sql操作,报错:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改Mysql默认密码为Mysql@123
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql@123' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.01 sec)
mysql> update user set host = "%" where user = "root";
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql@123';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)
mysql>
使用新密码登录mysql数据库