Centos

在 CentOS 8 上安裝 MySQL 5.7

  • July 28, 2020

我正在嘗試在 CentOS 8 上安裝 MySQL 5.7 社區伺服器,但我想不出一種方法來配置任何有效的 repo。

$ yum repolist all | grep mysql
CentOS-8 - AppStream                            2.2 kB/s | 4.3 kB     00:02    
CentOS-8 - Base                                 2.3 kB/s | 3.9 kB     00:01    
CentOS-8 - Extras                               2.1 kB/s | 1.5 kB     00:00    
CentOS-8 - PowerTools                           7.8 kB/s | 4.3 kB     00:00    

並使用 yum / dnf 安裝都給了我相同的結果:

$ sudo dnf install @mysql
Last metadata expiration check: 0:07:30 ago on Tue 03 Dec 2019 02:16:26 AM UTC.
Dependencies resolved.
==============================================================================================================
Package                              Arch      Version                                  Repository      Size
==============================================================================================================
Installing group/module packages:
mysql-server                         x86_64    8.0.17-3.module_el8.0.0+181+899d6349     AppStream       22 M
Installing dependencies:
mariadb-connector-c-config           noarch    3.0.7-1.el8                              AppStream       13 k
mecab                                x86_64    0.996-1.module_el8.0.0+41+ca30bab6.9     AppStream      397 k
mysql                                x86_64    8.0.17-3.module_el8.0.0+181+899d6349     AppStream       11 M
mysql-common                         x86_64    8.0.17-3.module_el8.0.0+181+899d6349     AppStream      143 k
mysql-errmsg                         x86_64    8.0.17-3.module_el8.0.0+181+899d6349     AppStream      557 k
protobuf-lite                        x86_64    3.5.0-7.el8                              AppStream      150 k
libaio                               x86_64    0.3.110-12.el8                           BaseOS          32 k
numactl-libs                         x86_64    2.0.12-2.el8                             BaseOS          36 k
policycoreutils-python-utils         noarch    2.8-16.1.el8                             BaseOS         228 k

甚至可以在 CentOS 8 上安裝 MySQL 5.7 嗎?

我按照此處的說明進行操作,並能夠在 CentOS 8 上安裝 MySQL 5.7

在 CentOS 8 / RHEL 8 Linux 上安裝 MySQL 5.7

[root@mysql01 ~]cat /etc/*release* | grep release
CentOS Linux release 8.0.1905 (Core)

[root@mysql01 ~]# rpm -qi mysql-community-server
Name        : mysql-community-server
Version     : 5.7.29
Release     : 1.el7
Architecture: x86_64

正如上面托尼所說,

$$ the accepted answer $$,這裡是如何在 centos 8 上安裝 mysql 5.7 的分步指南。 以防萬一部落格有一天宕機,這裡是所涉及的所有步驟的摘錄

step1:刪除mysql預設流

sudo dnf remove @mysql
sudo dnf module reset mysql && sudo dnf module disable mysql

第二步:添加mysql 5.7 repo

文件:

/etc/yum.repos.d/mysql-community.repo

內容:

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=0

step3:照常安裝

sudo dnf --enablerepo=mysql57-community install mysql-community-server

其餘步驟(密碼和安全安裝與 5.7 安裝相同)

#start
sudo systemctl enable --now mysqld.service
#read temp password
grep 'A temporary password' /var/log/mysqld.log |tail -1
#secure it
sudo mysql_secure_installation

引用自:https://unix.stackexchange.com/questions/555285