CentOS / Fedora 安装 MySQL5.7

卫劲
2023-12-01

CentOS / Fedora 安装 MySQL5.7

卸载旧版本

rpm -qa | grep mysql
# 删除相关rpm包
rpm -ev <rpm包名> --nodeps

安装

sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo yum -y install mysql57-community-release-el7-11.noarch.rpm
# 安装第一步下载的rpm文件,安装成功后/etc/yum.repos.d/目录下会增加两个文件
sudo yum repolist enabled | grep mysql
# 查看mysql57的安装源是否可用,如不可用请自行修改配置文件(/etc/yum.repos.d/mysql-community.repo)使mysql57下面的enable=1
# 若有mysql其它版本的安装源可用,也请自行修改配置文件使其enable=0
sudo yum install mysql-community-server

初始化

sudo service mysqld start
# 启动mysql服务
grep "password" /var/log/mysqld.log
# 查看root密码
mysql -u root -p
# 登陆mysql
Enter password: 
# 为了可以设置简单密码
set global validate_password_policy=0;
set global validate_password_length=4;
# 立即修改密码,执行其他操作报错:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('********'); 
# 我们创建密码为********

details

[bernard@fedora basic_rpm]$ sudo yum -y install mysql57-community-release-el7-11.noarch.rpm
[sudo] bernard 的密码:
Docker CE Stable - x86_64                                                                8.4 kB/s | 2.3 kB     00:00    
Errors during downloading metadata for repository 'docker-ce-stable':
  - Status code: 404 for https://mirrors.aliyun.com/docker-ce/linux/centos/34/x86_64/stable/repodata/repomd.xml (IP: 59.53.162.237)
Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Fedora 34 - x86_64 - Updates                                                             4.9 kB/s | 3.6 kB     00:00    
Fedora 34 - x86_64 - Updates                                                             1.5 MB/s | 3.2 MB     00:02    
Fedora Modular 34 - x86_64 - Updates                                                     4.4 kB/s | 6.7 kB     00:01    
正在忽略仓库:docker-ce-stable
依赖关系解决。
=========================================================================================================================
 软件包                                   架构                  版本                   仓库                         大小
=========================================================================================================================
安装:
 mysql57-community-release                noarch                el7-11                 @commandline                 25 k

事务概要
=========================================================================================================================
安装  1 软件包

总计:25 k
安装大小:31 k
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                          1/1 
  安装    : mysql57-community-release-el7-11.noarch                                                                  1/1 
  验证    : mysql57-community-release-el7-11.noarch                                                                  1/1 

已安装:
  mysql57-community-release-el7-11.noarch                                                                                

完毕!
[bernard@fedora basic_rpm]$ yum -y install mysql57-community-release-el7-11.noarch.rpm
错误:运行此命令需要管理员特权(多数系统下是root用户)。
[bernard@fedora basic_rpm]$ sudo yum repolist enabled | grep mysql
mysql-connectors-community       MySQL Connectors Community
mysql-tools-community            MySQL Tools Community
mysql57-community                MySQL 5.7 Community Server
[bernard@fedora basic_rpm]$ yum install mysql-community-server

错误:运行此命令需要管理员特权(多数系统下是root用户)。
[bernard@fedora basic_rpm]$ 
[bernard@fedora basic_rpm]$ sudo yum install mysql-community-server
Docker CE Stable - x86_64    12 kB/s | 2.3 kB     00:00    
Errors during downloading metadata for repository 'docker-ce-stable':
  - Status code: 404 for https://mirrors.aliyun.com/docker-ce/linux/centos/34/x86_64/stable/repodata/repomd.xml (IP: 59.53.162.241)
Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
MySQL Connectors Community   76 kB/s | 127 kB     00:01    
MySQL Tools Community       356 kB/s | 776 kB     00:02    
MySQL 5.7 Community Server  616 kB/s | 2.4 MB     00:04    
正在忽略仓库:docker-ce-stable
上次元数据过期检查:0:00:01 前,执行于 2021年11月06日 星期六 18时00分32秒。
依赖关系解决。
============================================================
 软件包                 架构   版本           仓库     大小
============================================================
安装:
 mysql-community-server x86_64 5.7.36-1.el7   mysql57-community
                                                      174 M
安装依赖关系:
 mysql-community-client x86_64 5.7.36-1.el7   mysql57-community
                                                       25 M
 mysql-community-common x86_64 5.7.36-1.el7   mysql57-community
                                                      310 k
 mysql-community-libs   x86_64 5.7.36-1.el7   mysql57-community
                                                      2.4 M
 ncurses-compat-libs    x86_64 6.2-4.20200222.fc34
                                              fedora  323 k
 numactl-libs           x86_64 2.0.14-3.fc34  fedora   30 k

事务概要
============================================================
安装  6 软件包

总下载:202 M
安装大小:879 M
确定吗?[y/N]: y
下载软件包:
(1/6): numactl-libs-2.0.14- 135 kB/s |  30 kB     00:00    
(2/6): ncurses-compat-libs- 971 kB/s | 323 kB     00:00    
(3/6): mysql-community-comm 200 kB/s | 310 kB     00:01    
(4/6): mysql-community-libs 376 kB/s | 2.4 MB     00:06    
(5/6): mysql-community-clie 742 kB/s |  25 MB     00:35    
(6/6): mysql-community-serv 1.9 MB/s | 174 MB     01:30    
------------------------------------------------------------
总计                        2.2 MB/s | 202 MB     01:32     
MySQL 5.7 Community Server   27 MB/s |  27 kB     00:00    
导入 GPG 公钥 0x5072E1F5:
 Userid: "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 指纹: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
 来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                             1/1 
  安装    : mysql-community-common-5.7.36-1.el7.x86_6   1/6 
  安装    : mysql-community-libs-5.7.36-1.el7.x86_64    2/6 
  运行脚本: mysql-community-libs-5.7.36-1.el7.x86_64    2/6 
  安装    : numactl-libs-2.0.14-3.fc34.x86_64           3/6 
  安装    : ncurses-compat-libs-6.2-4.20200222.fc34.x   4/6 
  安装    : mysql-community-client-5.7.36-1.el7.x86_6   5/6 
  运行脚本: mysql-community-server-5.7.36-1.el7.x86_6   6/6 
  安装    : mysql-community-server-5.7.36-1.el7.x86_6   6/6 
  运行脚本: mysql-community-server-5.7.36-1.el7.x86_6   6/6 
/usr/lib/tmpfiles.d/mysql.conf:23: Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.

  验证    : ncurses-compat-libs-6.2-4.20200222.fc34.x   1/6 
  验证    : numactl-libs-2.0.14-3.fc34.x86_64           2/6 
  验证    : mysql-community-client-5.7.36-1.el7.x86_6   3/6 
  验证    : mysql-community-common-5.7.36-1.el7.x86_6   4/6 
  验证    : mysql-community-libs-5.7.36-1.el7.x86_64    5/6 
  验证    : mysql-community-server-5.7.36-1.el7.x86_6   6/6 

已安装:
  mysql-community-client-5.7.36-1.el7.x86_64                
  mysql-community-common-5.7.36-1.el7.x86_64                
  mysql-community-libs-5.7.36-1.el7.x86_64                  
  mysql-community-server-5.7.36-1.el7.x86_64                
  ncurses-compat-libs-6.2-4.20200222.fc34.x86_64            
  numactl-libs-2.0.14-3.fc34.x86_64                         

完毕!
 类似资料: