2.2.3.2 离线RPM包安装MySQL
2.2.3.2.1 MySQL 8.0
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图66所示。
图66 下载MySQL RPM包
选择“MySQL Community (GPL) Downloads”,如图67所示。
图67 下载MySQL RPM包
选择“MySQL Community Server(MySQL社区服务器)”,如图68所示。
图68 下载MySQL RPM包
在“openSUSE”上安装MySQL:
"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:SUSE Linux Enterprise Server,然后选择”RPM Bundle“后面的”Download“,如图69所示。
图69 下载MySQL RPM包
opensuse15:~ # wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.43-1.sl15.x86_64.rpm-bundle.tar
opensuse15:~ # tar xf mysql-8.0.43-1.sl15.x86_64.rpm-bundle.tar
opensuse15:~ # rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023
方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错
opensuse15:~ # rpm -ivh mysql-community-client-plugins-8.0.43-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-common-8.0.43-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-libs-8.0.43-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-client-8.0.43-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-icu-data-files-8.0.43-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-server-8.0.43-1.sl15.x86_64.rpm
方法2:zypper命令安装,从”https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html“网址看到安装文档
opensuse15:~ # zypper install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.sl15.x86_64.rpm
继续安装MySQL:
opensuse15:~ # systemctl enable --now mysql
opensuse15:~ # ls /var/lib/mysql
#ib_16384_0.dblwr auto.cnf ca.pem ibdata1 mysql.sock public_key.pem undo_001
#ib_16384_1.dblwr binlog.000001 client-cert.pem ibtmp1 mysql.sock.lock server-cert.pem undo_002
#innodb_redo binlog.index client-key.pem mysql performance_schema server-key.pem
#innodb_temp ca-key.pem ib_buffer_pool mysql.ibd private_key.pem sys
opensuse15:~ # mysql -V
mysql Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)
opensuse15:~ # systemctl status mysql
● mysql.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-10-03 15:15:20 CST; 29s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 13833 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 13897 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 2250)
CPU: 5.358s
CGroup: /system.slice/mysql.service
└─13897 /usr/sbin/mysqld
Oct 03 15:15:12 opensuse15 systemd[1]: Starting MySQL Server...
Oct 03 15:15:19 opensuse15 (mysqld)[13897]: mysql.service: Referenced but unset environment variable evaluates t>
Oct 03 15:15:20 opensuse15 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
opensuse15:~ # grep password /var/log/mysql/mysqld.log
2025-10-03T07:15:15.023729Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qlyCwXu%K7.Z
# "qlyCwXu%K7.Z"就是MySQL的初始密码
# 修改mysql密码
opensuse15:~ # mysqladmin -uroot -p'qlyCwXu%K7.Z' 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'
# 上面报错提示密码太简单
opensuse15:~ # mysqladmin -uroot -p'qlyCwXu%K7.Z' 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.
opensuse15:~ # 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.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: 10
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: less
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: 3 min 10 sec
Threads: 2 Questions: 8 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.042
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
2.2.3.2.2 MySQL 8.4
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图70所示。
图70 下载MySQL RPM包
选择“MySQL Community (GPL) Downloads”,如图71所示。
图71 下载MySQL RPM包
选择“MySQL Community Server(MySQL社区服务器)”,如图72所示。
图72 下载MySQL RPM包
在“openSUSE”上安装MySQL:
"Select Version(选择版本)"为:8.0.43,“Select Operating System(选择操作系统)”为:SUSE Linux Enterprise Server,然后选择”RPM Bundle“后面的”Download“,如图73所示。
图73 下载MySQL RPM包
opensuse15:~ # wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.6-1.sl15.x86_64.rpm-bundle.tar
opensuse15:~ # tar xf mysql-8.4.6-1.sl15.x86_64.rpm-bundle.tar
opensuse15:~ # rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023
方法1:rpm命令安装,要按下面执行的顺序安装,否则会报错
opensuse15:~ # rpm -ivh mysql-community-client-plugins-8.4.6-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-common-8.4.6-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-libs-8.4.6-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-client-8.4.6-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-icu-data-files-8.4.6-1.sl15.x86_64.rpm
opensuse15:~ # rpm -ivh mysql-community-server-8.4.6-1.sl15.x86_64.rpm
方法2:zypper命令安装,从”https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html“网址看到安装文档
opensuse15:~ # zypper install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.sl15.x86_64.rpm
继续安装MySQL:
opensuse15:~ # systemctl enable --now mysql
opensuse15:~ # ls /var/lib/mysql
#ib_16384_0.dblwr auto.cnf ca.pem ibdata1 mysql.sock private_key.pem sys
#ib_16384_1.dblwr binlog.000001 client-cert.pem ibtmp1 mysql.sock.lock public_key.pem undo_001
#innodb_redo binlog.index client-key.pem mysql mysql_upgrade_history server-cert.pem undo_002
#innodb_temp ca-key.pem ib_buffer_pool mysql.ibd performance_schema server-key.pem
opensuse15:~ # mysql -V
mysql Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)
opensuse15:~ # systemctl status mysql
● mysql.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-10-03 16:29:00 CST; 30s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 13709 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 13771 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 2250)
CPU: 4.747s
CGroup: /system.slice/mysql.service
└─13771 /usr/sbin/mysqld
Oct 03 16:28:53 opensuse15 systemd[1]: Starting MySQL Server...
Oct 03 16:28:59 opensuse15 (mysqld)[13771]: mysql.service: Referenced but unset environment variable evaluates t>
Oct 03 16:29:00 opensuse15 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
opensuse15:~ # grep password /var/log/mysql/mysqld.log
2025-10-03T08:28:56.486012Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: w/#MU*%7LP9U
# "w/#MU*%7LP9U"就是MySQL的初始密码
# 修改mysql密码
opensuse15:~ # mysqladmin -uroot -p'w/#MU*%7LP9U' 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'
# 上面报错提示密码太简单
opensuse15:~ # mysqladmin -uroot -p'w/#MU*%7LP9U' 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.
opensuse15:~ # 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: less
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 30 sec
Threads: 2 Questions: 9 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.100
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye