当前位置:Gxlcms > 数据库问题 > 如何使用 Yum Repository 安装指定版本的 MySQL

如何使用 Yum Repository 安装指定版本的 MySQL

时间:2021-07-01 10:21:17 帮助过:16人阅读

from cached hostfile Resolving Dependencies --> Running transaction check ---> Package mysql-community-client.x86_64 0:8.0.12-1.el7 will be installed --> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.0 for package: mysql-community-client-8.0.12-1.el7.x86_64 --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 ---> Package mysql-community-libs.x86_64 0:8.0.12-1.el7 will be obsoleting --> Processing Dependency: mysql-community-common(x86-64) >= 8.0.0 for package: mysql-community-libs-8.0.12-1.el7.x86_64 --> Running transaction check ---> Package mysql-community-common.x86_64 0:8.0.12-1.el7 will be installed ---> Package mysql-community-libs-compat.x86_64 0:8.0.12-1.el7 will be obsoleting --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================================================== Installing: mysql-community-client x86_64 8.0.12-1.el7 mysql80-community 26 M mysql-community-libs x86_64 8.0.12-1.el7 mysql80-community 2.2 M replacing mariadb-libs.x86_64 1:5.5.56-2.el7 mysql-community-libs-compat x86_64 8.0.12-1.el7 mysql80-community 2.1 M replacing mariadb-libs.x86_64 1:5.5.56-2.el7 Installing for dependencies: mysql-community-common x86_64 8.0.12-1.el7 mysql80-community 541 k Transaction Summary ================================================================================================================================================================================================================== Install 3 Packages (+1 Dependent package) Total download size: 30 M

可以看到 如果我 y 同意上面的信息,就会安装 8.0 的 MySQL 社区版。

现在我们需要调整成 5.6 的版本。

如果机器上有安装 yum-config-manager or dnf config-manager 这两个工具的话可以使用:

for platforms that are not dnf-enabled:

shell> sudo yum-config-manager --disable mysql80-community
shell> sudo yum-config-manager --enable mysql56-community
For dnf
-enabled platforms: shell> sudo dnf config-manager --disable mysql80-community shell> sudo dnf config-manager --enable mysql56-community

来修改成自己想要的版本。如果像我这样。。。裸机啥都没有也有方法可以修改,我们去刚次啊提到的 /etc/yum.repos.d/ 下,找到 mysql-community.repo 编辑他。

可以看到 8.0 版本的信息是这样的

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

我们将 enabled=1 改成 0 

并且将我们想要使用的 5.6 改成 1即可。让我们再使用 yum install mysql-community-server 命令安装 社区版 MySQL 5.6 版本。(注意,上面提到的版本 enable。同一时间只能有一个版本处于 enable 状态)


[root@iz2ze46vymskz5z22xevegz yum.repos.d]# yum 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.6.41-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.41-2.el7 for package: mysql-community-server-5.6.41-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.41-2.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.41-2.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.41-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.6.41-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.6.41-2.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.6.41-2.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.6.41-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.41-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.41-2.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.41-2.el7 will be obsoleting
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


==================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.6.41-2.el7 mysql56-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 5.6.41-2.el7 mysql56-community 59 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
mysql-community-client x86_64 5.6.41-2.el7 mysql56-community 19 M
mysql-community-common x86_64 5.6.41-2.el7 mysql56-community 257 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k


Transaction Summary
==================================================================================================================================================================================================================
Install 2 Packages (+10 Dependent packages)


Total download size: 82 M

 

我们确定后开始安装。

安装完成后使用 /bin/systemctl start mysqld.service 启动 MySQL 

然后 大功告成!

[root@iz2ze46vymskz5z22xevegz yum.repos.d]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

完成安装和启动之后,我们可以在 /etc/my.conf 找到 MySQL 的配置文件, 默认数据存放位置是 /var/lib/mysql。

安装好之后默认 root 账户是没有密码的。设置 root 的密码使用

mysql> SET PASSWORD = PASSWORD(‘123456‘); 

之后就是各自配置需要的内容即可!

 

Reference:

https://dev.mysql.com/downloads/repo/yum/  Download MySQL Yum Repository

https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/  A Quick Guide to Using the MySQL Yum Repository

https://support.ruckuswireless.com/articles/000002490  What is a GA release?

 

如何使用 Yum Repository 安装指定版本的 MySQL

标签:技术   习惯   fast   rpc   manage   gre   from   for   64bit   

人气教程排行