一、安装YUM Repo
1、由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件。
下载命令:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2、然后进行repo的安装:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo mysql-community-source.repo
3.1、安装命令:
yum install mysql-server
报错如一下:
[root-bigdata-test007 yum.repos.d]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.37-1.el7 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.37-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.37-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: MySQL-python-1.2.5-1.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: MySQL-python-1.2.5-1.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.37-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.37-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-7.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.37-1.el7 mysql57-community 2.4 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-libs-compat x86_64 5.7.37-1.el7 mysql57-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 5.7.37-1.el7 mysql57-community 174 M
Installing for dependencies:
mysql-community-client x86_64 5.7.37-1.el7 mysql57-community 25 M
mysql-community-common x86_64 5.7.37-1.el7 mysql57-community 311 k
Updating for dependencies:
postfix x86_64 2:2.10.1-9.el7 base 2.4 M
Transaction Summary
===========================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Upgrade ( 1 Dependent package)
Total size: 206 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
症状:
官方 MySQL 存储库的 GPG 密钥已过期,无法安装或更新 MySQL 包。为 “MySQL 5.7 社区服务器” 存储库列出的 GPG 密钥已经安装,但它们对于这个包不正确
解决方案:
Note
If you are using RPM 4.1 and it complains about (GPG) NOT OK (MISSING KEYS: GPG#3a79bd29), even though you have imported the MySQL public build key into your own GPG keyring, you need to import the key into the RPM keyring first. RPM 4.1 no longer uses your personal GPG keyring (or GPG itself). Rather, RPM maintains a separate keyring because it is a system-wide application and a user’s GPG public keyring is a user-specific file. To import the MySQL public key into the RPM keyring, first obtain the key, then use rpm --import to import the key. For example:
可以在运行安装程序之前导入2022年的密钥:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
然后在重新安装
yum -y install mysql-server就可以正常安装了
[root@dbos-bigdata-test007 yum.repos.d]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.37-1.el7 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.37-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.37-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: MySQL-python-1.2.5-1.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: MySQL-python-1.2.5-1.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.37-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.37-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-7.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.37-1.el7 mysql57-community 2.4 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-libs-compat x86_64 5.7.37-1.el7 mysql57-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 5.7.37-1.el7 mysql57-community 174 M
Installing for dependencies:
mysql-community-client x86_64 5.7.37-1.el7 mysql57-community 25 M
mysql-community-common x86_64 5.7.37-1.el7 mysql57-community 311 k
Updating for dependencies:
postfix x86_64 2:2.10.1-9.el7 base 2.4 M
Transaction Summary
===========================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Upgrade ( 1 Dependent package)
Total size: 206 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[root@dbos-bigdata-test007 yum.repos.d]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
[root@dbos-bigdata-test007 yum.repos.d]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.37-1.el7 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.37-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.37-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: MySQL-python-1.2.5-1.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: MySQL-python-1.2.5-1.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.37-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.37-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-7.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.37-1.el7 mysql57-community 2.4 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-libs-compat x86_64 5.7.37-1.el7 mysql57-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 5.7.37-1.el7 mysql57-community 174 M
Installing for dependencies:
mysql-community-client x86_64 5.7.37-1.el7 mysql57-community 25 M
mysql-community-common x86_64 5.7.37-1.el7 mysql57-community 311 k
Updating for dependencies:
postfix x86_64 2:2.10.1-9.el7 base 2.4 M
Transaction Summary
===========================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Upgrade ( 1 Dependent package)
Total size: 206 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-5.7.37-1.el7.x86_64 1/8
Installing : mysql-community-libs-5.7.37-1.el7.x86_64 2/8
Installing : mysql-community-libs-compat-5.7.37-1.el7.x86_64 3/8
Installing : mysql-community-client-5.7.37-1.el7.x86_64 4/8
Installing : mysql-community-server-5.7.37-1.el7.x86_64 5/8
Updating : 2:postfix-2.10.1-9.el7.x86_64 6/8
Cleanup : 2:postfix-2.10.1-7.el7.x86_64 7/8
Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 8/8
Verifying : 2:postfix-2.10.1-9.el7.x86_64 1/8
Verifying : mysql-community-libs-compat-5.7.37-1.el7.x86_64 2/8
Verifying : mysql-community-libs-5.7.37-1.el7.x86_64 3/8
Verifying : mysql-community-common-5.7.37-1.el7.x86_64 4/8
Verifying : mysql-community-server-5.7.37-1.el7.x86_64 5/8
Verifying : mysql-community-client-5.7.37-1.el7.x86_64 6/8
Verifying : 2:postfix-2.10.1-7.el7.x86_64 7/8
Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 8/8
Installed:
mysql-community-libs.x86_64 0:5.7.37-1.el7 mysql-community-libs-compat.x86_64 0:5.7.37-1.el7 mysql-community-server.x86_64 0:5.7.37-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.37-1.el7 mysql-community-common.x86_64 0:5.7.37-1.el7
Dependency Updated:
postfix.x86_64 2:2.10.1-9.el7
Replaced:
mariadb-libs.x86_64 1:5.5.60-1.el7_5
Complete!