MySQL包安装(二)
2.2.1.2 MySQL 8.4
在Rocky 10和Almalinux 10上安装MySQL:
[root@rocky10 ~]# yum list mysql*-server --showduplicates
Last metadata expiration check: 0:00:29 ago on Tue 10 Jun 2025 11:20:22 AM CST.
Available Packages
mysql8.4-server.x86_64 8.4.4-2.el10 appstream
[root@rocky10 ~]# yum install -y mysql8.4-server
[root@rocky10 ~]# systemctl enable --now mysqld
[root@rocky10 ~]# ls /var/lib/mysql
auto.cnf client-key.pem '#innodb_redo' mysql_upgrade_history public_key.pem
binlog.000001 '#ib_16384_0.dblwr' '#innodb_temp' mysql_upgrade_info server-cert.pem
binlog.index '#ib_16384_1.dblwr' mysql mysqlx.sock server-key.pem
ca-key.pem ib_buffer_pool mysql.ibd mysqlx.sock.lock sys
ca.pem ibdata1 mysql.sock performance_schema undo_001
client-cert.pem ibtmp1 mysql.sock.lock private_key.pem undo_002
[root@rocky10 ~]# mysql -V
mysql Ver 8.4.4 for Linux on x86_64 (Source distribution)
[root@rocky10 ~]# systemctl status mysqld
● mysqld.service - MySQL 8.4 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
Active: active (running) since Tue 2025-06-10 11:22:48 CST; 32s ago
Invocation: 9156f6bbf370431887df1a3d38689b85
Process: 1529 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 1555 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Main PID: 1628 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 10497)
Memory: 440.3M (peak: 454.9M)
CPU: 2.949s
CGroup: /system.slice/mysqld.service
└─1628 /usr/libexec/mysqld --basedir=/usr
Jun 10 11:22:44 rocky10 systemd[1]: Starting mysqld.service - MySQL 8.4 database server...
Jun 10 11:22:44 rocky10 mysql-prepare-db-dir[1555]: Initializing MySQL database
Jun 10 11:22:48 rocky10 systemd[1]: Started mysqld.service - MySQL 8.4 database server.
[root@rocky10 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.4 Source distribution
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.4 for Linux on x86_64 (Source distribution)
Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.4.4 Source distribution
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: 58 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 120 Flush tables: 3 Open tables: 36 Queries per second avg: 0.103
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
在CentOS Stream 10上安装MySQL:
[root@centos10 ~]# yum list mysql-server --showduplicates
Last metadata expiration check: 0:02:19 ago on Fri 18 Apr 2025 08:47:00 PM CST.
Available Packages
mysql-server.x86_64 8.4.2-1.el10 appstream
mysql-server.x86_64 8.4.2-4.el10 appstream
mysql-server.x86_64 8.4.2-5.el10 appstream
[root@centos10 ~]# yum install -y mysql-server
[root@centos10 ~]# systemctl enable --now mysqld
[root@centos10 ~]# ls /var/lib/mysql
auto.cnf client-cert.pem ibdata1 mysql.ibd mysqlx.sock server-cert.pem
binlog.000001 client-key.pem ibtmp1 mysql.sock mysqlx.sock.lock server-key.pem
binlog.index '#ib_16384_0.dblwr' '#innodb_redo' mysql.sock.lock performance_schema sys
ca-key.pem '#ib_16384_1.dblwr' '#innodb_temp' mysql_upgrade_history private_key.pem undo_001
ca.pem ib_buffer_pool mysql mysql_upgrade_info public_key.pem undo_002
[root@centos10 ~]# mysql -V
mysql Ver 8.4.2 for Linux on x86_64 (Source distribution)
[root@centos10 ~]# systemctl status mysqld
● mysqld.service - MySQL 8.4 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-04-18 20:52:36 CST; 1min 29s ago
Invocation: 88e292c61b504209b59f1c6c66e8a394
Process: 1460 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 1483 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Main PID: 1556 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 10497)
Memory: 446.1M (peak: 454M)
CPU: 3.678s
CGroup: /system.slice/mysqld.service
└─1556 /usr/libexec/mysqld --basedir=/usr
Apr 18 20:52:31 centos10 systemd[1]: Starting mysqld.service - MySQL 8.4 database server...
Apr 18 20:52:32 centos10 mysql-prepare-db-dir[1483]: Initializing MySQL database
Apr 18 20:52:36 centos10 systemd[1]: Started mysqld.service - MySQL 8.4 database server.
[root@centos10 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.2 Source distribution
Copyright (c) 2000, 2024, 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.2 for Linux on x86_64 (Source distribution)
Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.4.2 Source distribution
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 54 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 120 Flush tables: 3 Open tables: 36 Queries per second avg: 0.052
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
在Rocky 8/9、Almalinux 8/9、CentOS Stream 8/9、openEuler 22.03/24.03 LTS、AnolisOS 8/23、OpenCloudOS 8/9、Kylin Server v10、UOS Server v20上安装MySQL:
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图6所示。
图6 下载Yum仓库包
选择“MySQL Community (GPL) Downloads”,如图7所示。
图7 下载Yum仓库包
选择“MySQL Yum Repository(MySQL Yum资源库)”,如图8所示。
图8 下载Yum仓库包
然后根据系统版本下载相应的安装包,如图9所示。
图9 下载Yum仓库包
Rocky 9、Almalinux 9、CentOS Stream 9、AnolisOS 23、OpenCloudOS 9:
# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget
[root@rocky9 ~]# wget https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
[root@rocky9 ~]# rpm -ivh mysql84-community-release-el9-1.noarch.rpm
[root@rocky9 ~]# yum makecache
[root@rocky9 ~]# yum list mysql-community-server --showduplicates
Last metadata expiration check: 0:00:06 ago on Fri 18 Apr 2025 07:37:00 PM CST.
Available Packages
mysql-community-server.x86_64 8.4.0-1.el9 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.2-1.el9 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.3-1.el9 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.4-1.el9 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.5-1.el9 mysql-8.4-lts-community
[root@rocky9 ~]# yum install -y mysql-community-server
[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.5 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 Sat 2025-04-12 21:14:16 CST; 49s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 12094 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 12159 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 10892)
Memory: 443.0M
CPU: 3.806s
CGroup: /system.slice/mysqld.service
└─12159 /usr/sbin/mysqld
Apr 12 21:14:11 rocky9 systemd[1]: Starting MySQL Server...
Apr 12 21:14:16 rocky9 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
[root@rocky9 ~]# grep password /var/log/mysqld.log
2025-04-12T13:52:56.917890Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jqdeiDdgi3_I
# "jqdeiDdgi3_I"就是MySQL的初始密码
# 修改mysql密码
[root@rocky9 ~]# mysqladmin -uroot -p'jqdeiDdgi3_I' 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'jqdeiDdgi3_I' 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.4.5 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.5 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.5 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: 59 sec
Threads: 2 Questions: 9 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.152
--------------
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、AnolisOS 8、OpenCloudOS 8:
# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
[root@rocky8 ~]# yum install -y wget
[root@rocky8 ~]# wget https://dev.mysql.com/get/mysql84-community-release-el8-1.noarch.rpm
[root@rocky8 ~]# rpm -ivh mysql84-community-release-el8-1.noarch.rpm
[root@rocky8 ~]# yum makecache
[root@rocky8 ~]# yum list mysql-community-server --showduplicates
Last metadata expiration check: 0:01:43 ago on Sat 12 Apr 2025 11:29:44 PM CST.
Error: No matching Packages to list
# 找不到安装包
在“Rocky 8、Almalinux 8、CentOS Stream 8、AnolisOS 8、OpenCloudOS 8”操作系统上添加镜像仓库后,找不到安装包,需要从官方网站下载安装包来安装。
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图10所示。
图10 下载MySQL RPM包
选择“MySQL Community (GPL) Downloads”,如图11所示。
图11 下载MySQL RPM包
选择“MySQL Community Server(MySQL社区服务器)”,如图12所示。
图12 下载MySQL RPM包
"Select Version(选择版本)"为:8.4.5 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 Bundel“后面的”Download“,如图13所示。
图13 下载MySQL RPM包
[root@rocky8 ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.4/mysql-8.4.5-1.el8.x86_64.rpm-bundle.tar
[root@rocky8 ~]# tar xf mysql-8.4.5-1.el8.x86_64.rpm-bundle.tar
[root@rocky8 ~]# yum install -y perl libaio
[root@rocky8 ~]# rpm -ivh mysql-community-client-plugins-8.4.5-1.el8.x86_64.rpm
[root@rocky8 ~]# rpm -ivh mysql-community-common-8.4.5-1.el8.x86_64.rpm
[root@rocky8 ~]# rpm -ivh mysql-community-libs-8.4.5-1.el8.x86_64.rpm
[root@rocky8 ~]# rpm -ivh mysql-community-client-8.4.5-1.el8.x86_64.rpm
[root@rocky8 ~]# rpm -ivh mysql-community-icu-data-files-8.4.5-1.el8.x86_64.rpm
[root@rocky8 ~]# yum install -y net-tools
[root@rocky8 ~]# rpm -ivh mysql-community-server-8.4.5-1.el8.x86_64.rpm
[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.5 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 Sat 2025-04-19 01:13:21 CST; 35s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 15045 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 15112 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 12176)
Memory: 469.9M
CGroup: /system.slice/mysqld.service
└─15112 /usr/sbin/mysqld
Apr 19 01:13:17 anolis8 systemd[1]: Starting MySQL Server...
Apr 19 01:13:21 anolis8 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
[root@rocky8 ~]# grep password /var/log/mysqld.log
2025-04-18T17:13:19.074870Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: gOtp+U:/L11&
# "y7:Fc>lcCpl!"就是MySQL的初始密码
# 修改mysql密码
[root@rocky8 ~]# mysqladmin -uroot -p'gOtp+U:/L11&' 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'gOtp+U:/L11&' 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: [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.5 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.5 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.5 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 48 sec
Threads: 2 Questions: 9 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.083
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
openEuler 22.03/24.03 LTS、Kylin Server v10、UOS Server v20:
# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
[root@openeuler2403 ~]# yum install -y wget
[root@openeuler2403 ~]# wget https://dev.mysql.com/get/mysql84-community-release-el8-1.noarch.rpm
[root@openeuler2403 ~]# rpm -ivh mysql84-community-release-el8-1.noarch.rpm
[root@openeuler2403 ~]# yum makecache
[root@openeuler2403 ~]# yum list mysql-community-server --showduplicates
Last metadata expiration check: 0:00:19 ago on Fri 18 Apr 2025 03:09:05 PM CST.
Available Packages
mysql-community-server.x86_64 8.4.0-1.el8 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.2-1.el8 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.3-1.el8 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.4-1.el8 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.5-1.el8 mysql-8.4-lts-communit
[root@openeuler2403 ~]# yum install -y mysql-community-server
[root@openeuler2403 ~]# systemctl enable --now mysqld
[root@openeuler2403 ~]# 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@openeuler2403 ~]# mysql -V
mysql Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
[root@openeuler2403 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-04-18 15:25:52 CST; 38s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1793 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1859 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 8901)
Memory: 467.2M ()
CGroup: /system.slice/mysqld.service
└─1859 /usr/sbin/mysqld
Apr 18 15:25:48 openeuler2403 systemd[1]: Starting MySQL Server...
Apr 18 15:25:51 openeuler2403 (mysqld)[1859]: mysqld.service: Referenced but unset environment variable evaluates to>
Apr 18 15:25:52 openeuler2403 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
[root@openeuler2403 ~]# grep password /var/log/mysqld.log
2025-04-18T07:25:49.630875Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: beM?N(3yyz&y
# "jqdeiDdgi3_I"就是MySQL的初始密码
# 修改mysql密码
[root@openeuler2403 ~]# mysqladmin -uroot -p'beM?N(3yyz&y' 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@openeuler2403 ~]# mysqladmin -uroot -p'beM?N(3yyz&y' 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@openeuler2403 ~]# 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.5 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.5 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.5 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 18 sec
Threads: 2 Questions: 12 Slow queries: 0 Opens: 140 Flush tables: 3 Open tables: 56 Queries per second avg: 0.086
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
在CentOS 7上安装MySQL:
# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
[root@centos7 ~]# yum install -y wget
[root@centos7 ~]# wget https://dev.mysql.com/get/mysql84-community-release-el7-1.noarch.rpm
[root@centos7 ~]# rpm -ivh mysql84-community-release-el7-1.noarch.rpm
[root@centos7 ~]# yum makecache
[root@centos7 ~]# yum list mysql-community-server --showduplicates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
mysql-community-server.x86_64 8.4.0-1.el7 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.2-1.el7 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.3-1.el7 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.4-1.el7 mysql-8.4-lts-community
mysql-community-server.x86_64 8.4.5-1.el7 mysql-8.4-lts-communit
[root@centos7 ~]# yum install -y mysql-community-server
[root@centos7 ~]# systemctl enable --now mysqld
[root@centos7 ~]# mysql -V
mysql Ver 8.4.5 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 Sat 2025-04-19 04:07:32 CST; 38s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1185 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1249 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─1249 /usr/sbin/mysqld
Apr 19 04:07:27 centos7 systemd[1]: Starting MySQL Server...
Apr 19 04:07:32 centos7 systemd[1]: Started MySQL Server.
# 获取mysql初始密码
[root@centos7 ~]# grep password /var/log/mysqld.log
2025-04-18T20:07:29.114303Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: )puUpc=M8VJk
# “)puUpc=M8VJk”就是mysql的初始密码
# 修改mysql密码
[root@centos7 ~]# mysqladmin -uroot -p')puUpc=M8VJk' 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')puUpc=M8VJk' 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 10
Server version: 8.4.5 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.5 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.5 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 11 sec
Threads: 2 Questions: 12 Slow queries: 0 Opens: 140 Flush tables: 3 Open tables: 56 Queries per second avg: 0.091
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
在Kylin Server V11上安装MySQL:
在“Kylin Server V11”操作系统官方没有镜像仓库,需要从官方网站下载安装包来安装。
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图14所示。
图14 下载MySQL RPM包
选择“MySQL Community (GPL) Downloads”,如图15所示。
图15 下载MySQL RPM包
选择“MySQL Community Server(MySQL社区服务器)”,如图16所示。
图16 下载MySQL RPM包
"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 Bundel“后面的”Download“,如图17所示。
图17 下载MySQL RPM包
# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget
[root@kylin11 ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.6-1.el9.x86_64.rpm-bundle.tar
[root@kylin11 ~]# tar xf mysql-8.4.6-1.el9.x86_64.rpm-bundle.tar
[root@kylin11 ~]# yum install -y perl libaio
[root@kylin11 ~]# rpm -ivh mysql-community-client-plugins-8.4.6-1.el9.x86_64.rpm
[root@kylin11 ~]# rpm -ivh mysql-community-common-8.4.6-1.el9.x86_64.rpm
[root@kylin11 ~]# rpm -ivh mysql-community-libs-8.4.6-1.el9.x86_64.rpm
[root@kylin11 ~]# rpm -ivh mysql-community-client-8.4.6-1.el9.x86_64.rpm
[root@kylin11 ~]# rpm -ivh mysql-community-icu-data-files-8.4.6-1.el9.x86_64.rpm
[root@kylin11 ~]# yum install -y net-tools
[root@kylin11 ~]# rpm -ivh mysql-community-server-8.4.6-1.el9.x86_64.rpm
[root@kylin11 ~]# systemctl enable --now mysqld
[root@kylin11 ~]# 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@kylin11 ~]# mysql -V
mysql Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)
[root@kylin11 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
Active: active (running) since Sat 2025-09-13 13:30:44 CST; 1min 39s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2982 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 3048 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 8626)
Memory: 436.5M ()
CGroup: /system.slice/mysqld.service
└─3048 /usr/sbin/mysqld
Sep 13 13:30:40 kylin11 systemd[1]: Starting MySQL Server...
Sep 13 13:30:43 kylin11 (mysqld)[3048]: mysqld.service: Referenced but unset environment variable evaluates to a>
Sep 13 13:30:44 kylin11 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
[root@kylin11 ~]# grep password /var/log/mysqld.log
2025-09-13T05:30:41.773786Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: S4-=kZYlF,cJ
# "S4-=kZYlF,cJ"就是MySQL的初始密码
# 修改mysql密码
[root@kylin11 ~]# mysqladmin -uroot -p'S4-=kZYlF,cJ' 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@kylin11 ~]# mysqladmin -uroot -p'S4-=kZYlF,cJ' 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@kylin11 ~]# 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: 4 min 9 sec
Threads: 2 Questions: 12 Slow queries: 0 Opens: 140 Flush tables: 3 Open tables: 56 Queries per second avg: 0.048
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
2.2.2 Apt资源库安装MySQL
2.2.2.1 MySQL 8.0
在Ubuntu上安装MySQL:
root@ubuntu2404:~# apt-cache madison mysql-server
mysql-server | 8.0.42-0ubuntu0.24.04.1 | https://mirrors.aliyun.com/ubuntu noble-updates/main amd64 Packages
mysql-server | 8.0.42-0ubuntu0.24.04.1 | https://mirrors.aliyun.com/ubuntu noble-security/main amd64 Packages
mysql-server | 8.0.36-2ubuntu3 | https://mirrors.aliyun.com/ubuntu noble/main amd64 Packages
root@ubuntu2404:~# apt install -y mysql-server
root@ubuntu2404:~# systemctl enable --now mysql
root@ubuntu2404:~# mysql -V
mysql Ver 8.0.42-0ubuntu0.24.04.1 for Linux on x86_64 ((Ubuntu))
root@ubuntu2404:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Mon 2025-05-26 19:51:22 CST; 1min 3s ago
Main PID: 2211 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 2214)
Memory: 364.0M (peak: 378.3M)
CPU: 1.604s
CGroup: /system.slice/mysql.service
└─2211 /usr/sbin/mysqld
May 26 19:51:21 ubuntu2404 systemd[1]: Starting mysql.service - MySQL Community Server...
May 26 19:51:22 ubuntu2404 systemd[1]: Started mysql.service - MySQL Community Server.
root@ubuntu2404:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.42-0ubuntu0.24.04.1 (Ubuntu)
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.42-0ubuntu0.24.04.1 for Linux on x86_64 ((Ubuntu))
Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.42-0ubuntu0.24.04.1 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /var/run/mysqld/mysqld.sock
Binary data as: Hexadecimal
Uptime: 1 min 26 sec
Threads: 2 Questions: 5 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.058
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
在Debian上安装MySQL:
root@debian12:~# wget https://repo.mysql.com/mysql-apt-config_0.8.29-1_all.deb
root@debian12:~# dpkg -i mysql-apt-config_0.8.29-1_all.deb
Selecting previously unselected package mysql-apt-config.
dpkg: regarding mysql-apt-config_0.8.29-1_all.deb containing mysql-apt-config, pre-dependency problem:
mysql-apt-config pre-depends on gnupg
gnupg is not installed. # 提示没有安装gnupg
dpkg: error processing archive mysql-apt-config_0.8.29-1_all.deb (--install):
pre-dependency problem - not installing mysql-apt-config
Errors were encountered while processing:
mysql-apt-config_0.8.29-1_all.deb
root@debian12:~# apt install -y gnupg
root@debian12:~# dpkg -i mysql-apt-config_0.8.29-1_all.deb
使用箭头键导航到 “MySQL Server & Cluster (Currently selected: mysql-8.0)” 选项,然后按下 Enter 键,这将允许你选择具体的 MySQL 服务器版本,如图18所示。
图18 选择MySQL版本
在版本选择界面中,选择 “mysql-8.0” 版本(或其他你想要的版本)并按 Enter,如图19所示。
图19 选择MySQL版本
使用箭头键导航到 “Ok” 选项,按下 Enter
键,确认并保存配置,如图20所示。
图20 确认选择
root@debian12:~# apt update
root@debian12:~# apt-cache madison mysql-community-server
mysql-community-server | 8.0.42-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.0 amd64 Packages
mysql-community | 8.0.42-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.0 Sources
root@debian12:~# apt install -y mysql-community-server
输入MySQL root用户密码,然后按下 Enter 键,如图21所示。
图21 输入MySQL root用户密码
在下面提示直接按下 Enter 键,如图22所示。
图22 确认提示信息
选择“Use Strong Password Encryption (RECOMMENDED)”,然后按下 Enter 键,如图23所示。
图23 选择默认身份验证插件
root@debian12:~# systemctl enable --now mysql
root@debian12:~# mysql -V
mysql Ver 8.0.42 for Linux on x86_64 (MySQL Community Server - GPL)
root@debian12:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Mon 2025-05-26 21:52:30 CST; 1min 1s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2575 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 2273)
Memory: 370.3M
CPU: 1.506s
CGroup: /system.slice/mysql.service
└─2575 /usr/sbin/mysqld
May 26 21:52:30 debian12 systemd[1]: Starting mysql.service - MySQL Community Server...
May 26 21:52:30 debian12 systemd[1]: Started mysql.service - MySQL Community Server.
root@debian12:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.42 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.42 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.42 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/run/mysqld/mysqld.sock
Binary data as: Hexadecimal
Uptime: 1 min 22 sec
Threads: 2 Questions: 7 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 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
2.2.2.2 MySQL 8.4
在Ubuntu、Debian上安装MySQL:
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图24所示。
图24 下载APT仓库包
选择“MySQL Community (GPL) Downloads”,如图25所示。
图25 下载APT仓库包
选择“MySQL APT Repository(MySQL APT资源库)”,如图26所示。
图26 下载APT仓库包
然后根据系统版本下载相应的安装包,如图27所示。
图27 下载APT仓库包
在Ubuntu上安装MySQL:
root@ubuntu2404:~# wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb
root@ubuntu2404:~# dpkg -i mysql-apt-config_0.8.34-1_all.deb
使用箭头键导航到 “MySQL Server & Cluster (Currently selected: mysql-8.4-lts)” 选项,然后按下 Enter 键,这将允许你选择具体的 MySQL 服务器版本,如图28所示。
图28 选择MySQL版本
在版本选择界面中,选择 “mysql-8.4-lts” 版本(或其他你想要的版本)并按 Enter,如图29所示。
图29 选择MySQL版本
使用箭头键导航到 “Ok” 选项,按下 Enter
键,确认并保存配置,如图30所示。
图30 确认选择
root@ubuntu2404:~# apt update
root@ubuntu2404:~# apt-cache madison mysql-community-server
mysql-community-server | 8.4.5-1ubuntu24.04 | http://repo.mysql.com/apt/ubuntu noble/mysql-8.4-lts amd64 Packages
mysql-community | 8.4.5-1ubuntu24.04 | http://repo.mysql.com/apt/ubuntu noble/mysql-8.4-lts Sources
root@ubuntu2404:~# apt install -y mysql-community-server
输入MySQL root用户密码,然后按下 Enter 键,如图31所示。
图31 输入MySQL root用户密码
root@ubuntu2404:~# systemctl enable --now mysql
root@ubuntu2404:~# mysql -V
mysql Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
root@ubuntu2404:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Fri 2025-04-18 21:27:29 CST; 1min 44s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2546 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 2214)
Memory: 428.5M (peak: 442.6M)
CPU: 2.447s
CGroup: /system.slice/mysql.service
└─2546 /usr/sbin/mysqld
Apr 18 21:27:28 ubuntu2404 systemd[1]: Starting mysql.service - MySQL Community Server...
Apr 18 21:27:29 ubuntu2404 systemd[1]: Started mysql.service - MySQL Community Server.
root@ubuntu2204:~# mysql
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.5 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.5 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.5 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/run/mysqld/mysqld.sock
Binary data as: Hexadecimal
Uptime: 2 min 14 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.044
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
在Debian上安装MySQL:
root@debian12:~# wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb
root@debian12:~# dpkg -i mysql-apt-config_0.8.34-1_all.deb
dpkg: regarding mysql-apt-config_0.8.34-1_all.deb containing mysql-apt-config, pre-dependency problem:
mysql-apt-config pre-depends on gnupg
gnupg is not installed. # 提示没有安装gnupg
dpkg: error processing archive mysql-apt-config_0.8.34-1_all.deb (--install):
pre-dependency problem - not installing mysql-apt-config
Errors were encountered while processing:
mysql-apt-config_0.8.34-1_all.deb
root@debian12:~# apt install -y gnupg
root@debian12:~# dpkg -i mysql-apt-config_0.8.34-1_all.deb
使用箭头键导航到 “MySQL Server & Cluster (Currently selected: mysql-8.4-lts)” 选项,然后按下 Enter 键,这将允许你选择具体的 MySQL 服务器版本,如图32所示。
图32 选择MySQL版本
在版本选择界面中,选择 “mysql-8.4-lts” 版本(或其他你想要的版本)并按 Enter,如图33所示。
图33 选择MySQL版本
使用箭头键导航到 “Ok” 选项,按下 Enter
键,确认并保存配置,如图34所示。
图34 确认选择
root@debian12:~# apt update
root@debian12:~# apt-cache madison mysql-community-server
mysql-community-server | 8.4.5-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 Packages
mysql-community | 8.4.5-1debian12 | http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts Sources
root@debian12:~# apt install -y mysql-community-server
输入MySQL root用户密码,然后按下 Enter 键,如图35所示。
图35 输入MySQL root用户密码
root@debian12:~# systemctl enable --now mysql
root@debian12:~# mysql -V
mysql Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
root@debian12:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Fri 2025-04-18 22:52:11 CST; 1min 4s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2115 (mysqld)
Status: "Server is operational"
Tasks: 34 (limit: 2273)
Memory: 436.0M
CPU: 1.437s
CGroup: /system.slice/mysql.service
└─2115 /usr/sbin/mysqld
Apr 18 22:52:10 debian12 systemd[1]: Starting mysql.service - MySQL Community Server...
Apr 18 22:52:11 debian12 systemd[1]: Started mysql.service - MySQL Community Server.
root@debian12:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.5 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.5 for Linux on x86_64 (MySQL Community Server - GPL)
Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.4.5 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/run/mysqld/mysqld.sock
Binary data as: Hexadecimal
Uptime: 1 min 29 sec
Threads: 2 Questions: 6 Slow queries: 0 Opens: 119 Flush tables: 3 Open tables: 38 Queries per second avg: 0.067
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
2.2.3 SUSE资源库安装MySQL
2.2.3.1 MySQL 8.0
opensuse15:~ # wget https://repo.mysql.com//mysql80-community-release-sl15-1.noarch.rpm
opensuse15:~ # rpm -Uvh mysql80-community-release-sl15-1.noarch.rpm
opensuse15:~ # rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
opensuse15:~ # zypper refresh
opensuse15:~ # zypper search "mysql-community-server"
Loading repository data...
Warning: Repository 'Update repository of openSUSE Backports' metadata expired since 2025-05-26 06:48:52 CST.
Warning: Repository 'Main Update Repository' metadata expired since 2025-05-17 16:03:01 CST.
Warning: Repository metadata expired: Check if 'autorefresh' is turned on (zypper lr), otherwise
manually refresh the repository (zypper ref). If this does not solve the issue, it could be that
you are using a broken mirror or the server has actually discontinued to support the repository.
Reading installed packages...
S | Name | Summary | Type
--+------------------------------+----------------------------------------------+--------
| mysql-community-server | A very fast and reliable SQL database server | package
| mysql-community-server-debug | The debug version of MySQL server | package
opensuse15:~ # zypper info "mysql-community-server"
Loading repository data...
Warning: Repository 'Update repository of openSUSE Backports' metadata expired since 2025-05-26 06:48:52 CST.
Warning: Repository 'Main Update Repository' metadata expired since 2025-05-17 16:03:01 CST.
Warning: Repository metadata expired: Check if 'autorefresh' is turned on (zypper lr), otherwise
manually refresh the repository (zypper ref). If this does not solve the issue, it could be that
you are using a broken mirror or the server has actually discontinued to support the repository.
Reading installed packages...
Information for package mysql-community-server:
-----------------------------------------------
Repository : MySQL 8.0 Community Server
Name : mysql-community-server
Version : 8.0.42-1.sl15
Arch : x86_64
Vendor : Oracle and/or its affiliates
Installed Size : 401.1 MiB
Installed : No
Status : not installed
Source package : mysql-community-8.0.42-1.sl15.src
Upstream URL : http://www.mysql.com/
Summary : A very fast and reliable SQL database server
Description :
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates
The MySQL software has Dual Licensing, which means you can use the MySQL
software free of charge under the GNU General Public License
(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
the GPL. See the chapter "Licensing and Support" in the manual for
further info.
The MySQL web site (http://www.mysql.com/) provides the latest news and
information about the MySQL software. Also please see the documentation
and the manual for more information.
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.
opensuse15:~ # zypper install -y mysql-community-server
opensuse15:~ # systemctl enable --now mysql
opensuse15:~ # mysql -V
mysql Ver 8.0.42 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 Tue 2025-05-27 11:38:33 CST; 35s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 13955 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 14019 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 2250)
CPU: 6.301s
CGroup: /system.slice/mysql.service
└─14019 /usr/sbin/mysqld
May 27 11:38:25 opensuse15 systemd[1]: Starting MySQL Server...
May 27 11:38:32 opensuse15 (mysqld)[14019]: mysql.service: Referenced but unset environment variable evaluates t>
May 27 11:38:33 opensuse15 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
opensuse15:~ # grep 'temporary password' /var/log/mysql/mysqld.log
2025-05-27T03:38:27.924298Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rhjiMe?S1g*S
# "rhjiMe?S1g*S"就是MySQL的初始密码
# 修改mysql密码
[root@rocky9 ~]# mysqladmin -uroot -p'rhjiMe?S1g*S' 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'rhjiMe?S1g*S' 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 11
Server version: 8.0.42 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.42 for Linux on x86_64 (MySQL Community Server - GPL)
Connection id: 11
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 8.0.42 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 38 sec
Threads: 2 Questions: 11 Slow queries: 0 Opens: 140 Flush tables: 3 Open tables: 56 Queries per second avg: 0.069
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
2.2.3.2 MySQL 8.4
在openSUSE上安装MySQL:
去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图36所示。
图36 下载SUSE仓库包
选择“MySQL Community (GPL) Downloads”,如图37所示。
图37 下载SUSE仓库包
选择“MySQL SUSE Repository(MySQL SUSE资源库)”,如图38所示。
图38 下载SUSE仓库包
然后根据系统版本下载相应的安装包,如图39所示。
图39 下载SUSE仓库包
opensuse15:~ # wget https://dev.mysql.com/get/mysql84-community-release-sl15-1.noarch.rpm
opensuse15:~ # rpm -Uvh mysql84-community-release-sl15-1.noarch.rpm
opensuse15:~ # zypper update -y mysql84-community-release
opensuse15:~ # zypper refresh
opensuse15:~ # zypper install -y mysql-community-server
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.5 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-04-18 22:06:26 CST; 54s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 14025 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 14088 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 2250)
CPU: 5.552s
CGroup: /system.slice/mysql.service
└─14088 /usr/sbin/mysqld
Apr 18 22:06:18 opensuse15 systemd[1]: Starting MySQL Server...
Apr 18 22:06:24 opensuse15 (mysqld)[14088]: mysql.service: Referenced but unset environment variable evaluates to an>
Apr 18 22:06:26 opensuse15 systemd[1]: Started MySQL Server.
# 获取MySQL初始密码
opensuse15:~ # grep 'temporary password' /var/log/mysql/mysqld.log
2025-04-18T14:06:21.043078Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Wwm:uvwie3sx
# "Wwm:uvwie3sx"就是MySQL的初始密码
# 修改mysql密码
[root@rocky9 ~]# mysqladmin -uroot -p'Wwm:uvwie3sx' 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'Wwm:uvwie3sx' 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 11
Server version: 8.4.5 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.5 for Linux on x86_64 (MySQL Community Server - GPL)
Connection id: 11
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 8.4.5 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 22 sec
Threads: 2 Questions: 12 Slow queries: 0 Opens: 140 Flush tables: 3 Open tables: 56 Queries per second avg: 0.059
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
- 点赞
- 收藏
- 关注作者
评论(0)