1. 添加Mysql5.7仓库
CentOS 7的默认yum仓库中并没有MySQL5.7,我们需要手动添加,好在MySQL官方提供了仓库的地址,所以我们能够比较简单地安装MySQL。
rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2. 确认Mysql仓库成功添加
yum repolist all | grep mysql | grep enabled
[root@iZ2zeizsw2xjgxwhbbsxchZ ~]# yum repolist all | grep mysql | grep enabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 108
mysql-tools-community/x86_64 MySQL Tools Community enabled: 90
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 347
[root@iZ2zeizsw2xjgxwhbbsxchZ ~]#
3. 安装Mysql5.7
yum -y install mysql-community-server
[root@iZ2zeizsw2xjgxwhbbsxchZ ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.26-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.26-1.el7 for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mysql-community-client.x86_64 0:5.7.26-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.26-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.26-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(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.26-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.26-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.26-1.el7 mysql57-community 2.2 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-libs-compat x86_64 5.7.26-1.el7 mysql57-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 5.7.26-1.el7 mysql57-community 166 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
mysql-community-client x86_64 5.7.26-1.el7 mysql57-community 24 M
mysql-community-common x86_64 5.7.26-1.el7 mysql57-community 274 k
Transaction Summary
================================================================================================================================================================================================================
Install 3 Packages (+3 Dependent packages)
Total download size: 194 M
Downloading packages:
(1/6): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY ] 87 kB/s | 423 kB 00:38:11 ETA
Public key for mysql-community-common-5.7.26-1.el7.x86_64.rpm is not installed
(2/6): mysql-community-common-5.7.26-1.el7.x86_64.rpm | 274 kB 00:00:02
(3/6): mysql-community-libs-5.7.26-1.el7.x86_64.rpm | 2.2 MB 00:00:01
(4/6): mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm | 2.0 MB 00:00:01
(5/6): mysql-community-client-5.7.26-1.el7.x86_64.rpm | 24 MB 00:00:08
(6/6): mysql-community-server-5.7.26-1.el7.x86_64.rpm | 166 MB 00:00:39
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.3 MB/s | 194 MB 00:00:44
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
▽
# For advice on how to change settings please see
Package : mysql57-community-release-el7-11.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-5.7.26-1.el7.x86_64 1/7
Installing : mysql-community-libs-5.7.26-1.el7.x86_64 2/7
Installing : mysql-community-client-5.7.26-1.el7.x86_64 3/7
Installing : libaio-0.3.109-13.el7.x86_64 4/7
Installing : mysql-community-server-5.7.26-1.el7.x86_64 5/7
Installing : mysql-community-libs-compat-5.7.26-1.el7.x86_64 6/7
Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 7/7
Verifying : mysql-community-server-5.7.26-1.el7.x86_64 1/7
Verifying : mysql-community-client-5.7.26-1.el7.x86_64 2/7
Verifying : mysql-community-libs-5.7.26-1.el7.x86_64 3/7
Verifying : mysql-community-libs-compat-5.7.26-1.el7.x86_64 4/7
Verifying : mysql-community-common-5.7.26-1.el7.x86_64 5/7
Verifying : libaio-0.3.109-13.el7.x86_64 6/7
Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 7/7
Installed:
mysql-community-libs.x86_64 0:5.7.26-1.el7 mysql-community-libs-compat.x86_64 0:5.7.26-1.el7 mysql-community-server.x86_64 0:5.7.26-1.el7
Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:5.7.26-1.el7 mysql-community-common.x86_64 0:5.7.26-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.60-1.el7_5
Complete!
4.Mysql基本操作
systemctl start mysqld 启动mysql
systemctl enable mysqld 设置开机启动
systemctl status mysqld 查看启动状态
推荐:
服务器最低86元/年
拼团链接: 阿里云点击进入