CentOS7安装MySQL5.7

DogJay 2019-07-27 系统运维 5282人已围观

在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB。

1.下载并安装MySQL官方的 Yum Repository

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@VM_0_6_centos ~]wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
--2019-07-27 14:12:54--  http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sentawaiting response... 301 Moved Permanently
Locationhttps://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [following]
--2019-07-27 14:12:55--  https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sentawaiting response... 302 Found
Locationhttps://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm [following]
--2019-07-27 14:13:01--  https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.57.113.239
Connecting to repo.mysql.com (repo.mysql.com)|23.57.113.239|:443... connected.
HTTP request sentawaiting response... 200 OK
Length25548 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-10.noarch.rpm
100%[==================================================================================>] 25,548      --.-K/s   in 0.1s    
2019-07-27 14:13:02 (213 KB/s) - ‘mysql57-community-release-el7-10.noarch.rpm’ saved [25548/25548]
-cNo such file or directory
No URLs found in -c.
FINISHED --2019-07-27 14:13:02--
Total wall clock time7.6s
Downloaded1 files25K in 0.1s (213 KB/s)

2.使用上面的命令就直接下载了安装用的Yum Repository,大概25KB的样子,然后就可以直接yum安装了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[root@VM_0_6_centos ~]yum -y install mysql57-community-release-el7-10.noarch.rpm
Loaded pluginsfastestmirrorlangpacks
Examining mysql57-community-release-el7-10.noarch.rpmmysql57-community-release-el7-10.noarch
Marking mysql57-community-release-el7-10.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-10 will be installed
--> Finished Dependency Resolution
epel/7/x86_64                                                                                        | 5.3 kB  00:00:00     
epel/7/x86_64/group_gz                                                                               |  88 kB  00:00:00     
epel/7/x86_64/updateinfo                                                                             | 993 kB  00:00:00     
epel/7/x86_64/primary_db                                                                             | 6.8 MB  00:00:01     
extras/7/x86_64                                                                                      | 3.4 kB  00:00:00     
extras/7/x86_64/primary_db                                                                           | 205 kB  00:00:00     
os/7/x86_64                                                                                          | 3.6 kB  00:00:00     
os/7/x86_64/group_gz                                                                                 | 166 kB  00:00:00     
os/7/x86_64/primary_db                                                                               | 6.0 MB  00:00:00     
updates/7/x86_64                                                                                     | 3.4 kB  00:00:00     
updates/7/x86_64/primary_db                                                                          | 6.5 MB  00:00:00     
Dependencies Resolved
============================================================================================================================
 Package                            Arch            Version         Repository                                         Size
============================================================================================================================
Installing:
 mysql57-community-release          noarch          el7-10          /mysql57-community-release-el7-10.noarch           30 k
Transaction Summary
============================================================================================================================
Install  1 Package
Total size30 k
Installed size30 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql57-community-release-el7-10.noarch                                                                  1