CentOS 7上安装MySQL 5.7
MySQL 5.7是当前最新稳定版本,它的新特性包括更好的性能和可扩展性,更好的JSON支持和更大的安全性。在CentOS 7上,MySQL 5.7安装过程如下:
- 更新系统
在安装MySQL 5.7之前,我们需要先更新系统:
yum update -y
- 添加MySQL Yum Repository
下载MySQL Yum Repository Configurator并安装:
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm -y
- 安装MySQL
使用yum安装MySQL 5.7:
yum install mysql-community-server -y
- 启动MySQL
启动MySQL服务并设置MySQL在系统启动时自动启动:
systemctl start mysqld
systemctl enable mysqld
- 登录MySQL
使用以下命令登录MySQL:
mysql -u root -p
- 升级MySQL 5.7
如果你已经安装了MySQL 5.6,并且你想升级到MySQL 5.7,请参考以下步骤:
#下载mysql57-community-release-el7-9.noarch.rpm
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
#删除mysql-community-release-el7-5.noarch.rpm
yum remove mysql-community-release-el7-5.noarch.rpm -y
#安装mysql57-community-release-el7-9.noarch.rpm
yum localinstall mysql57-community-release-el7-9.noarch.rpm -y
#卸载mysql
yum remove mysql-community-server -y
#安装mysql5.7
yum install mysql-community-server -y
#启动mysql
systemctl start mysqld
示例1:安装MySQL 5.7
假设我们的服务器是全新的,没有安装MySQL。根据上面的攻略,我们执行以下命令来安装MySQL 5.7:
yum update -y
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm -y
yum install mysql-community-server -y
systemctl start mysqld
systemctl enable mysqld
mysql -u root -p
示例2:升级MySQL 5.7
假设我们已经安装了MySQL 5.6,现在想升级到MySQL 5.7。根据上面的攻略,我们执行以下命令来升级MySQL:
#下载mysql57-community-release-el7-9.noarch.rpm
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
#删除mysql-community-release-el7-5.noarch.rpm
yum remove mysql-community-release-el7-5.noarch.rpm -y
#安装mysql57-community-release-el7-9.noarch.rpm
yum localinstall mysql57-community-release-el7-9.noarch.rpm -y
#卸载mysql
yum remove mysql-community-server -y
#安装mysql5.7
yum install mysql-community-server -y
#启动mysql
systemctl start mysqld
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Centos MySQL 5.7安装、升级教程 - Python技术站