MySQL包安装 -- RHEL系列(离线RPM包安装MySQL)

本文涉及的产品
云数据库 RDS SQL Server,基础系列 2核4GB
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS PostgreSQL Serverless,0.5-4RCU 50GB 3个月
推荐场景:
对影评进行热评分析
简介: 本文详细介绍在Rocky、CentOS、AlmaLinux、openEuler等主流Linux系统上,通过离线RPM包安装MySQL 8.0和8.4版本的完整步骤,涵盖下载、依赖处理、rpm/yum安装、服务启动、密码设置等关键环节,适用于多种企业级环境部署需求。

2.1.1.2 离线RPM包安装MySQL

2.2.1.2.1 MySQL 8.0

去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图6所示。

t6

图6 下载MySQL RPM包

选择“MySQL Community (GPL) Downloads”,如图7所示。

t7

图7 下载MySQL RPM包

选择“MySQL Community Server(MySQL社区服务器)”,如图8所示。

t8

图8 下载MySQL RPM包

在“Rocky 9、AlmaLinux 9、CentOS Stream 9、openEuler 24.03 LTS、AnolisOS 23、OpenCloudOS 9、Kylin Server v11”上安装MySQL:

"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 9 / Oracle Linux 9 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图9所示。

t9

图9 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@rocky9 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.43-1.el9.x86_64.rpm-bundle.tar

[root@rocky9 ~]# tar xf mysql-8.0.43-1.el9.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@rocky9 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@rocky9 ~]# rpm -ivh mysql-community-client-plugins-8.0.43-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-common-8.0.43-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-libs-8.0.43-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-client-8.0.43-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-icu-data-files-8.0.43-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-server-8.0.43-1.el9.x86_64.rpm 
warning: mysql-community-server-8.0.43-1.el9.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.0.43-1.el9.x86_64
    net-tools is needed by mysql-community-server-8.0.43-1.el9.x86_64
# 提示,需要perl和net-tools依赖包

[root@rocky9 ~]# yum install -y perl net-tools

[root@rocky9 ~]# rpm -ivh mysql-community-server-8.0.43-1.el9.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.0/en/linux-installation-rpm.html“网址看到安装文档

[root@rocky9 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.el9.x86_64.rpm

继续安装MySQL:

[root@rocky9 ~]# systemctl enable --now mysqld

[root@rocky9 ~]# ls /var/lib/mysql
 auto.cnf        client-cert.pem      ibdata1         mysql.ibd            public_key.pem    undo_002
 binlog.000001   client-key.pem       ibtmp1          mysql.sock           server-cert.pem
 binlog.index   '#ib_16384_0.dblwr'  '#innodb_redo'   mysql.sock.lock      server-key.pem
 ca-key.pem     '#ib_16384_1.dblwr'  '#innodb_temp'   performance_schema   sys
 ca.pem          ib_buffer_pool       mysql           private_key.pem      undo_001

[root@rocky9 ~]# mysql -V
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)

[root@rocky9 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
     Active: active (running) since Wed 2025-10-01 11:06:53 CST; 42s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 17070 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
   Main PID: 17137 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 10844)
     Memory: 453.0M
        CPU: 2.668s
     CGroup: /system.slice/mysqld.service
             └─17137 /usr/sbin/mysqld

Oct 01 11:06:49 rocky9 systemd[1]: Starting MySQL Server...
Oct 01 11:06:53 rocky9 systemd[1]: Started MySQL Server.

# 获取MySQL初始密码
[root@rocky9 ~]# grep password /var/log/mysqld.log
2025-10-01T03:06:51.232903Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qh:/Xbz1YwgL
# "qh:/Xbz1YwgL"就是MySQL的初始密码

# 修改mysql密码
[root@rocky9 ~]# mysqladmin -uroot -p'qh:/Xbz1YwgL' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@rocky9 ~]# mysqladmin -uroot -p'qh:/Xbz1YwgL' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@rocky9 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.43 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.0.43 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            1 min 55 sec

Threads: 2  Questions: 8  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.069
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye

在“Rocky 8、AlmaLinux 8、CentOS Stream 8、openEuler 22.03 LTS、AnolisOS 8、OpenCloudOS 8、Kylin Server v10、UOS Server v20”上安装MySQL:

"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 8 / Oracle Linux 8 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图10所示。

t10

图10 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@rocky8 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.43-1.el8.x86_64.rpm-bundle.tar

[root@rocky8 ~]# tar xf mysql-8.0.43-1.el8.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@rocky8 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@rocky8 ~]# rpm -ivh mysql-community-client-plugins-8.0.43-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-common-8.0.43-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-libs-8.0.43-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-client-8.0.43-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-icu-data-files-8.0.43-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-server-8.0.43-1.el8.x86_64.rpm 
warning: mysql-community-server-8.0.43-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.0.43-1.el8.x86_64
    libaio.so.1()(64bit) is needed by mysql-community-server-8.0.43-1.el8.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.43-1.el8.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.43-1.el8.x86_64
    net-tools is needed by mysql-community-server-8.0.43-1.el8.x86_64
# 提示,需要perl、libaio和net-tools依赖包

[root@rocky8 ~]# yum install -y perl libaio net-tools

[root@rocky8 ~]# rpm -ivh mysql-community-server-8.0.43-1.el8.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.0/en/linux-installation-rpm.html“网址看到安装文档

[root@rocky8 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.el8.x86_64.rpm

继续安装MySQL:

[root@rocky8 ~]# systemctl enable --now mysqld

[root@rocky8 ~]# ls /var/lib/mysql
 auto.cnf        client-cert.pem      ibdata1         mysql.ibd            public_key.pem    undo_002
 binlog.000001   client-key.pem       ibtmp1          mysql.sock           server-cert.pem
 binlog.index   '#ib_16384_0.dblwr'  '#innodb_redo'   mysql.sock.lock      server-key.pem
 ca-key.pem     '#ib_16384_1.dblwr'  '#innodb_temp'   performance_schema   sys
 ca.pem          ib_buffer_pool       mysql           private_key.pem      undo_001

[root@rocky8 ~]# mysql -V
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)

[root@rocky8 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2025-10-01 11:46:51 CST; 40s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 14818 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 14886 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 10941)
   Memory: 431.0M
   CGroup: /system.slice/mysqld.service
           └─14886 /usr/sbin/mysqld

Oct 01 11:46:46 rocky8 systemd[1]: Starting MySQL Server...
Oct 01 11:46:51 rocky8 systemd[1]: Started MySQL Server.

# 获取MySQL初始密码
[root@rocky8 ~]# grep password /var/log/mysqld.log
2025-10-01T03:46:48.159739Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: t%?%brs=q2J9
# "t%?%brs=q2J9"就是MySQL的初始密码

# 修改mysql密码
[root@rocky8 ~]# mysqladmin -uroot -p't%?%brs=q2J9' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@rocky8 ~]# mysqladmin -uroot -p't%?%brs=q2J9' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@rocky8 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.43 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.0.43 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            2 min 19 sec

Threads: 2  Questions: 8  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.057
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye

在“CentOS 7”上安装MySQL:

"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图11所示。

t11

图11 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@centos7 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.43-1.el7.x86_64.rpm-bundle.tar

[root@centos7 ~]# tar xf mysql-8.0.43-1.el7.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@centos7 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@centos7 ~]# rpm -ivh mysql-community-client-plugins-8.0.43-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-common-8.0.43-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-libs-8.0.43-1.el7.x86_64.rpm 
warning: mysql-community-libs-8.0.43-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    mariadb-libs is obsoleted by mysql-community-libs-8.0.43-1.el7.x86_64
# 由于 mysql-community-libs 替代了 mariadb-libs,导致依赖关系冲突。

# 卸载 MariaDB 库
[root@centos7 ~]# yum remove -y mariadb-libs

[root@centos7 ~]# rpm -ivh mysql-community-libs-8.0.43-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-client-8.0.43-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-icu-data-files-8.0.43-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-server-8.0.43-1.el7.x86_64.rpm 
warning: mysql-community-server-8.0.43-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.0.43-1.el7.x86_64
    libaio.so.1()(64bit) is needed by mysql-community-server-8.0.43-1.el7.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.43-1.el7.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.43-1.el7.x86_64
    net-tools is needed by mysql-community-server-8.0.43-1.el7.x86_64
    perl(Getopt::Long) is needed by mysql-community-server-8.0.43-1.el7.x86_64
    perl(strict) is needed by mysql-community-server-8.0.43-1.el7.x86_64
# 提示,需要perl、libaio和net-tools依赖包

[root@centos7 ~]# yum install -y perl libaio net-tools

[root@centos7 ~]# rpm -ivh mysql-community-server-8.0.43-1.el7.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.0/en/linux-installation-rpm.html“网址看到安装文档

# 卸载 MariaDB 库
[root@centos7 ~]# yum remove -y mariadb-libs

[root@centos7 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.el7.x86_64.rpm

继续安装MySQL:

[root@centos7 ~]# systemctl enable --now mysqld

[root@centos7 ~]# ls /var/lib/mysql
auto.cnf       ca.pem             #ib_16384_1.dblwr  #innodb_redo  mysql.sock          public_key.pem   undo_001
binlog.000001  client-cert.pem    ib_buffer_pool     #innodb_temp  mysql.sock.lock     server-cert.pem  undo_002
binlog.index   client-key.pem     ibdata1            mysql         performance_schema  server-key.pem
ca-key.pem     #ib_16384_0.dblwr  ibtmp1             mysql.ibd     private_key.pem     sys

[root@centos7 ~]# mysql -V
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)

[root@centos7 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2025-10-01 20:05:47 CST; 35s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 1205 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1271 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─1271 /usr/sbin/mysqld

Oct 01 20:05:42 centos7 systemd[1]: Starting MySQL Server...
Oct 01 20:05:47 centos7 systemd[1]: Started MySQL Server.

# 获取MySQL初始密码
[root@centos7 ~]# grep password /var/log/mysqld.log
2025-10-01T12:05:44.478664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: W7#Fzwshj0P-
# "W7#Fzwshj0P-"就是MySQL的初始密码

# 修改mysql密码
[root@centos7 ~]# mysqladmin -uroot -p'W7#Fzwshj0P-' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@centos7 ~]# mysqladmin -uroot -p'W7#Fzwshj0P-' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@centos7 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.43 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.0.43 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            1 min 42 sec

Threads: 2  Questions: 8  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.078
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
2.2.1.2.2 MySQL 8.4

去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图12所示。

t12

图12 下载MySQL RPM包

选择“MySQL Community (GPL) Downloads”,如图13所示。

t13

图13 下载MySQL RPM包

选择“MySQL Community Server(MySQL社区服务器)”,如图14所示。

t14

图14 下载MySQL RPM包

在“Rocky 10、AlmaLinux 10和CentOS Stream 10”上安装MySQL:

"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 10 / Oracle Linux 10 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图15所示。

t15

图15 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@rocky10 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.6-1.el10.x86_64.rpm-bundle.tar

[root@rocky10 ~]# tar xf mysql-8.4.6-1.el10.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@rocky10 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@rocky10 ~]# rpm -ivh mysql-community-client-plugins-8.4.6-1.el10.x86_64.rpm

[root@rocky10 ~]# rpm -ivh mysql-community-common-8.4.6-1.el10.x86_64.rpm

[root@rocky10 ~]# rpm -ivh mysql-community-libs-8.4.6-1.el10.x86_64.rpm

[root@rocky10 ~]# rpm -ivh mysql-community-client-8.4.6-1.el10.x86_64.rpm

[root@rocky10 ~]# rpm -ivh mysql-community-icu-data-files-8.4.6-1.el10.x86_64.rpm

[root@rocky10 ~]# rpm -ivh mysql-community-server-8.4.6-1.el10.x86_64.rpm 
warning: mysql-community-server-8.4.6-1.el10.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.4.6-1.el10.x86_64
    net-tools is needed by mysql-community-server-8.4.6-1.el10.x86_64
# 提示,需要perl和net-tools依赖包

[root@rocky10 ~]# yum install -y perl net-tools

[root@rocky10 ~]# rpm -ivh mysql-community-server-8.4.6-1.el10.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html“网址看到安装文档

[root@rocky10 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.4.6-1.el10.x86_64.rpm

继续安装MySQL:

[root@rocky10 ~]# systemctl enable --now mysqld

[root@rocky10 ~]# ls /var/lib/mysql
 auto.cnf        client-cert.pem      ibdata1         mysql.ibd               private_key.pem   undo_001
 binlog.000001   client-key.pem       ibtmp1          mysql.sock              public_key.pem    undo_002
 binlog.index   '#ib_16384_0.dblwr'  '#innodb_redo'   mysql.sock.lock         server-cert.pem
 ca-key.pem     '#ib_16384_1.dblwr'  '#innodb_temp'   mysql_upgrade_history   server-key.pem
 ca.pem          ib_buffer_pool       mysql           performance_schema      sys

[root@rocky10 ~]# mysql -V
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

[root@rocky10 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
     Active: active (running) since Wed 2025-10-01 14:57:28 CST; 33s ago
 Invocation: 011c0e0db8894ed680e43658126e5091
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 2191 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
   Main PID: 2257 (mysqld)
     Status: "Server is operational"
      Tasks: 35 (limit: 10481)
     Memory: 432.2M (peak: 446.1M)
        CPU: 2.342s
     CGroup: /system.slice/mysqld.service
             └─2257 /usr/sbin/mysqld

Oct 01 14:57:24 rocky10 systemd[1]: Starting mysqld.service - MySQL Server...
Oct 01 14:57:27 rocky10 (mysqld)[2257]: mysqld.service: Referenced but unset environment variable evaluates to a>
Oct 01 14:57:28 rocky10 systemd[1]: Started mysqld.service - MySQL Server.

# 获取MySQL初始密码
[root@rocky10 ~]# grep password /var/log/mysqld.log
2025-10-01T06:57:25.751263Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: o:=oBI30F+>a
# "o:=oBI30F+>a"就是MySQL的初始密码

# 修改mysql密码
[root@rocky10 ~]# mysqladmin -uroot -p'o:=oBI30F+>a' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@rocky10 ~]# mysqladmin -uroot -p'o:=oBI30F+>a' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@rocky10 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.4.6 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.4.6 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            2 min 4 sec

Threads: 2  Questions: 9  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.072
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye

在“Rocky 9、AlmaLinux 9、CentOS Stream 9、openEuler 24.03 LTS、AnolisOS 23、OpenCloudOS 9、Kylin Server v11”上安装MySQL:

"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 9 / Oracle Linux 9 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图16所示。

t16

图16 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@rocky9 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.6-1.el9.x86_64.rpm-bundle.tar

[root@rocky9 ~]# tar xf mysql-8.4.6-1.el9.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@rocky9 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@rocky9 ~]# rpm -ivh mysql-community-client-plugins-8.4.6-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-common-8.4.6-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-libs-8.4.6-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-client-8.4.6-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-icu-data-files-8.4.6-1.el9.x86_64.rpm

[root@rocky9 ~]# rpm -ivh mysql-community-server-8.4.6-1.el9.x86_64.rpm
warning: mysql-community-server-8.4.6-1.el9.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.4.6-1.el9.x86_64
    net-tools is needed by mysql-community-server-8.4.6-1.el9.x86_64
# 提示,需要perl和net-tools依赖包

[root@rocky9 ~]# yum install -y perl net-tools

[root@rocky9 ~]# rpm -ivh mysql-community-server-8.4.6-1.el9.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html“网址看到安装文档

[root@rocky9 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.4.6-1.el9.x86_64.rpm

继续安装MySQL:

[root@rocky9 ~]# systemctl enable --now mysqld

[root@rocky9 ~]# ls /var/lib/mysql
 auto.cnf        client-cert.pem      ibdata1         mysql.ibd               private_key.pem   undo_001
 binlog.000001   client-key.pem       ibtmp1          mysql.sock              public_key.pem    undo_002
 binlog.index   '#ib_16384_0.dblwr'  '#innodb_redo'   mysql.sock.lock         server-cert.pem
 ca-key.pem     '#ib_16384_1.dblwr'  '#innodb_temp'   mysql_upgrade_history   server-key.pem
 ca.pem          ib_buffer_pool       mysql           performance_schema      sys

[root@rocky9 ~]# mysql -V
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

[root@rocky9 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
     Active: active (running) since Wed 2025-10-01 15:15:21 CST; 33s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 16934 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
   Main PID: 16999 (mysqld)
     Status: "Server is operational"
      Tasks: 36 (limit: 10844)
     Memory: 434.2M
        CPU: 2.387s
     CGroup: /system.slice/mysqld.service
             └─16999 /usr/sbin/mysqld

Oct 01 15:15:17 rocky9 systemd[1]: Starting MySQL Server...
Oct 01 15:15:21 rocky9 systemd[1]: Started MySQL Server.

# 获取MySQL初始密码
[root@rocky9 ~]# grep password /var/log/mysqld.log
2025-10-01T07:15:18.447006Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ypt)iWaEy3vo
# "ypt)iWaEy3vo"就是MySQL的初始密码

# 修改mysql密码
[root@rocky9 ~]# mysqladmin -uroot -p'ypt)iWaEy3vo' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@rocky9 ~]# mysqladmin -uroot -p'ypt)iWaEy3vo' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@rocky9 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.4.6 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        10
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.4.6 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            1 min 31 sec

Threads: 2  Questions: 9  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.098
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye

在“Rocky 8、AlmaLinux 8、CentOS Stream 8、openEuler 22.03 LTS、AnolisOS 8、OpenCloudOS 8、Kylin Server v10、UOS Server v20”上安装MySQL:

"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 8 / Oracle Linux 8 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图17所示。

t17

图17 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@rocky8 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.6-1.el8.x86_64.rpm-bundle.tar

[root@rocky8 ~]# tar xf mysql-8.4.6-1.el8.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@rocky8 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@rocky8 ~]# rpm -ivh mysql-community-client-plugins-8.4.6-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-common-8.4.6-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-libs-8.4.6-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-client-8.4.6-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-icu-data-files-8.4.6-1.el8.x86_64.rpm

[root@rocky8 ~]# rpm -ivh mysql-community-server-8.4.6-1.el8.x86_64.rpm 
warning: mysql-community-server-8.4.6-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.4.6-1.el8.x86_64
    libaio.so.1()(64bit) is needed by mysql-community-server-8.4.6-1.el8.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.4.6-1.el8.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.4.6-1.el8.x86_64
    net-tools is needed by mysql-community-server-8.4.6-1.el8.x86_64
# 提示,需要perl、libaio和net-tools依赖包

[root@rocky8 ~]# yum install -y perl libaio net-tools

[root@rocky8 ~]# rpm -ivh mysql-community-server-8.4.6-1.el8.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html“网址看到安装文档

[root@rocky8 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.4.6-1.el8.x86_64.rpm

继续安装MySQL:

[root@rocky8 ~]# systemctl enable --now mysqld

[root@rocky8 ~]# ls /var/lib/mysql
 auto.cnf        client-cert.pem      ibdata1         mysql.ibd               private_key.pem   undo_001
 binlog.000001   client-key.pem       ibtmp1          mysql.sock              public_key.pem    undo_002
 binlog.index   '#ib_16384_0.dblwr'  '#innodb_redo'   mysql.sock.lock         server-cert.pem
 ca-key.pem     '#ib_16384_1.dblwr'  '#innodb_temp'   mysql_upgrade_history   server-key.pem
 ca.pem          ib_buffer_pool       mysql           performance_schema      sys

[root@rocky8 ~]# mysql -V
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

[root@rocky8 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2025-10-01 15:30:42 CST; 26s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 14468 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 14534 (mysqld)
   Status: "Server is operational"
    Tasks: 35 (limit: 10941)
   Memory: 436.1M
   CGroup: /system.slice/mysqld.service
           └─14534 /usr/sbin/mysqld

Oct 01 15:30:38 rocky8 systemd[1]: Starting MySQL Server...
Oct 01 15:30:42 rocky8 systemd[1]: Started MySQL Server.

# 获取MySQL初始密码
[root@rocky8 ~]# grep password /var/log/mysqld.log
2025-10-01T07:30:39.846407Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: o+=(4ofk5(Jv
# "o+=(4ofk5(Jv"就是MySQL的初始密码

# 修改mysql密码
[root@rocky8 ~]# mysqladmin -uroot -p'o+=(4ofk5(Jv' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@rocky8 ~]# mysqladmin -uroot -p'o+=(4ofk5(Jv' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@rocky8 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.4.6 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.4.6 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            1 min 35 sec

Threads: 2  Questions: 9  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.094
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye

在“CentOS 7”上安装MySQL:

"Select Version(选择版本)"为:8.4.6 LTS,“Select Operating System(选择操作系统)”为:Red Hat Enterprise Linux / Oracle Linux,"Select OS Version(选择操作系统版本)"为:Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86 , 64-bit),然后选择”RPM Bundle“后面的”Download“,如图18所示。

t18

图18 下载MySQL RPM包

# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

[root@centos7 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.6-1.el7.x86_64.rpm-bundle.tar

[root@centos7 ~]# tar xf mysql-8.4.6-1.el7.x86_64.rpm-bundle.tar

方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错

[root@centos7 ~]# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023

[root@centos7 ~]# rpm -ivh mysql-community-client-plugins-8.4.6-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-common-8.4.6-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-libs-8.4.6-1.el7.x86_64.rpm
warning: mysql-community-libs-8.4.6-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    mariadb-libs is obsoleted by mysql-community-libs-8.4.6-1.el7.x86_64
# 由于 mysql-community-libs 替代了 mariadb-libs,导致依赖关系冲突。

# 卸载 MariaDB 库
[root@centos7 ~]# yum remove -y mariadb-libs

[root@centos7 ~]# rpm -ivh mysql-community-libs-8.4.6-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-client-8.4.6-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-icu-data-files-8.4.6-1.el7.x86_64.rpm

[root@centos7 ~]# rpm -ivh mysql-community-server-8.4.6-1.el7.x86_64.rpm
warning: mysql-community-server-8.4.6-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
error: Failed dependencies:
    /usr/bin/perl is needed by mysql-community-server-8.4.6-1.el7.x86_64
    libaio.so.1()(64bit) is needed by mysql-community-server-8.4.6-1.el7.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.4.6-1.el7.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.4.6-1.el7.x86_64
    mysql-community-client(x86-64) >= 8.0.11 is needed by mysql-community-server-8.4.6-1.el7.x86_64
    net-tools is needed by mysql-community-server-8.4.6-1.el7.x86_64
    perl(Getopt::Long) is needed by mysql-community-server-8.4.6-1.el7.x86_64
    perl(strict) is needed by mysql-community-server-8.4.6-1.el7.x86_64
# 提示,需要perl、libaio和net-tools依赖包

[root@centos7 ~]# yum install -y perl libaio net-tools

[root@centos7 ~]# rpm -ivh mysql-community-server-8.4.6-1.el7.x86_64.rpm

方法2:yum命令安装,会自动安装依赖包,从”https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html“网址看到安装文档

# 卸载 MariaDB 库
[root@centos7 ~]# yum remove -y mariadb-libs

[root@centos7 ~]# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.4.6-1.el7.x86_64.rpm

继续安装MySQL:

[root@centos7 ~]# systemctl enable --now mysqld

[root@centos7 ~]# ls /var/lib/mysql
auto.cnf       client-cert.pem    ibdata1       mysql.ibd              private_key.pem  undo_001
binlog.000001  client-key.pem     ibtmp1        mysql.sock             public_key.pem   undo_002
binlog.index   #ib_16384_0.dblwr  #innodb_redo  mysql.sock.lock        server-cert.pem
ca-key.pem     #ib_16384_1.dblwr  #innodb_temp  mysql_upgrade_history  server-key.pem
ca.pem         ib_buffer_pool     mysql         performance_schema     sys

[root@centos7 ~]# mysql -V
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

[root@centos7 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2025-10-01 23:59:24 CST; 40s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 1275 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1339 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─1339 /usr/sbin/mysqld

Oct 01 23:59:19 centos7 systemd[1]: Starting MySQL Server...
Oct 01 23:59:24 centos7 systemd[1]: Started MySQL Server.

# 获取MySQL初始密码
[root@centos7 ~]# grep password /var/log/mysqld.log
2025-10-01T15:59:21.430023Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: sK4W5xLhmd_V
# "sK4W5xLhmd_V"就是MySQL的初始密码

# 修改mysql密码
[root@centos7 ~]# mysqladmin -uroot -p'sK4W5xLhmd_V' password 123456
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
# 上面报错提示密码太简单

[root@centos7 ~]# mysqladmin -uroot -p'sK4W5xLhmd_V' password Raymond@2025
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@centos7 ~]# mysql -uroot -p'Raymond@2025'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.4.6 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

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.

mysql> status
--------------
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.4.6 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/lib/mysql/mysql.sock
Binary data as:        Hexadecimal
Uptime:            1 min 45 sec

Threads: 2  Questions: 9  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 46  Queries per second avg: 0.085
--------------

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye

相关文章
|
8天前
|
存储 关系型数据库 分布式数据库
PostgreSQL 18 发布,快来 PolarDB 尝鲜!
PostgreSQL 18 发布,PolarDB for PostgreSQL 全面兼容。新版本支持异步I/O、UUIDv7、虚拟生成列、逻辑复制增强及OAuth认证,显著提升性能与安全。PolarDB-PG 18 支持存算分离架构,融合海量弹性存储与极致计算性能,搭配丰富插件生态,为企业提供高效、稳定、灵活的云数据库解决方案,助力企业数字化转型如虎添翼!
|
7天前
|
存储 人工智能 Java
AI 超级智能体全栈项目阶段二:Prompt 优化技巧与学术分析 AI 应用开发实现上下文联系多轮对话
本文讲解 Prompt 基本概念与 10 个优化技巧,结合学术分析 AI 应用的需求分析、设计方案,介绍 Spring AI 中 ChatClient 及 Advisors 的使用。
337 130
AI 超级智能体全栈项目阶段二:Prompt 优化技巧与学术分析 AI 应用开发实现上下文联系多轮对话
|
19天前
|
弹性计算 关系型数据库 微服务
基于 Docker 与 Kubernetes(K3s)的微服务:阿里云生产环境扩容实践
在微服务架构中,如何实现“稳定扩容”与“成本可控”是企业面临的核心挑战。本文结合 Python FastAPI 微服务实战,详解如何基于阿里云基础设施,利用 Docker 封装服务、K3s 实现容器编排,构建生产级微服务架构。内容涵盖容器构建、集群部署、自动扩缩容、可观测性等关键环节,适配阿里云资源特性与服务生态,助力企业打造低成本、高可靠、易扩展的微服务解决方案。
1331 8
|
7天前
|
人工智能 Java API
AI 超级智能体全栈项目阶段一:AI大模型概述、选型、项目初始化以及基于阿里云灵积模型 Qwen-Plus实现模型接入四种方式(SDK/HTTP/SpringAI/langchain4j)
本文介绍AI大模型的核心概念、分类及开发者学习路径,重点讲解如何选择与接入大模型。项目基于Spring Boot,使用阿里云灵积模型(Qwen-Plus),对比SDK、HTTP、Spring AI和LangChain4j四种接入方式,助力开发者高效构建AI应用。
329 122
AI 超级智能体全栈项目阶段一:AI大模型概述、选型、项目初始化以及基于阿里云灵积模型 Qwen-Plus实现模型接入四种方式(SDK/HTTP/SpringAI/langchain4j)
|
6天前
|
监控 JavaScript Java
基于大模型技术的反欺诈知识问答系统
随着互联网与金融科技发展,网络欺诈频发,构建高效反欺诈平台成为迫切需求。本文基于Java、Vue.js、Spring Boot与MySQL技术,设计实现集欺诈识别、宣传教育、用户互动于一体的反欺诈系统,提升公众防范意识,助力企业合规与用户权益保护。
|
18天前
|
机器学习/深度学习 人工智能 前端开发
通义DeepResearch全面开源!同步分享可落地的高阶Agent构建方法论
通义研究团队开源发布通义 DeepResearch —— 首个在性能上可与 OpenAI DeepResearch 相媲美、并在多项权威基准测试中取得领先表现的全开源 Web Agent。
1417 87
|
6天前
|
JavaScript Java 大数据
基于JavaWeb的销售管理系统设计系统
本系统基于Java、MySQL、Spring Boot与Vue.js技术,构建高效、可扩展的销售管理平台,实现客户、订单、数据可视化等全流程自动化管理,提升企业运营效率与决策能力。
|
7天前
|
弹性计算 安全 数据安全/隐私保护
2025年阿里云域名备案流程(新手图文详细流程)
本文图文详解阿里云账号注册、服务器租赁、域名购买及备案全流程,涵盖企业实名认证、信息模板创建、域名备案提交与管局审核等关键步骤,助您快速完成网站上线前的准备工作。
258 82
2025年阿里云域名备案流程(新手图文详细流程)