MySQL的最新版是8.0.x版本,与5.x版本相比,不仅仅快了很多,而且还带来了大量的更新和更快的性能,在读写工作负载,IO密集型工作负载中有着更加强劲的性能,使用了utf-8mb4作为默认字符集,同时增强了安全性。
1、首先安装rpm, 一个相当于加速的东西。
# rpm -Uvh
如有错误,见本文下面评论栏
2、列出CentOS 7.6当前支持的MySQL数据库,如下面所示
# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 118
mysql-connectors-community-source MySQL Connectors Community - Sour 禁用
mysql-tools-community/x86_64 MySQL Tools Community 启用: 95
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql-tools-preview/x86_64 MySQL Tools Preview 禁用
mysql-tools-preview-source MySQL Tools Preview - Source 禁用
mysql55-community/x86_64 MySQL 5.5 Community Server 禁用
mysql55-community-source MySQL 5.5 Community Server - Sour 禁用
mysql56-community/x86_64 MySQL 5.6 Community Server 禁用
mysql56-community-source MySQL 5.6 Community Server - Sour 禁用
mysql57-community/x86_64 MySQL 5.7 Community Server 启用: 364
mysql57-community-source MySQL 5.7 Community Server - Sour 禁用
mysql80-community/x86_64 MySQL 8.0 Community Server 禁用
mysql80-community-source MySQL 8.0 Community Server - Sour 禁用
从上面可以看出,会默认下载5.7版本的MySQL数据库,而8.0版本的默认是关闭的,先把5.7的禁用,启用MySQL 8.0数据库。
3、打开文件, 修改设置
# vi /etc/yum.repos.d/mysql-community.repo
输入命令后显示如下代码,每一个模块代表一个版本数据库。
其中可以看到5.7版本, enabled=1, 改为enabled=0, 禁用掉
另外可以看到8.0版本, enabled=0, 改为enabled=1, 开启
[mysql-connectors-community] name=MySQL Connectors Community baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community] name=MySQL Tools Community baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.5 [mysql55-community] name=MySQL 5.5 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [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 [mysql-tools-preview] name=MySQL Tools Preview baseurl=http://repo.mysql.com/yum/mysql-tools-preview/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
4、修改完之后查看可以用的MySQL版本
# yum repolist enabled | grep mysql