[root@centos8 mysql]# mysql -V mysql Ver 8.0.31 for Linux on aarch64 (MySQL Community Server - GPL) [root@centos8 mysql]#
最后就是启动服务,并将服务写入开机自启中,并查看服务状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[root@centos8 mysql]# systemctl enable mysqld && systemctl start mysqld && systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2025-05-13 21:18:02 CST; 23min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 12913 (mysqld) Status: "Server is operational" Tasks: 40 (limit: 14674) Memory: 405.5M CGroup: /system.slice/mysqld.service └─12913 /usr/sbin/mysqld
5月 13 21:17:58 centos8 systemd[1]: Starting MySQL Server... 5月 13 21:18:02 centos8 systemd[1]: Started MySQL Server. [root@centos8 mysql]#
五、MySQL初始化
MySQL安装完成后,需要做一些初始化操作,比方说更改默认密码等:
1 2
[root@centos8 mysql]# grep "temporary password" /var/log/mysqld.log 2025-05-13T13:17:59.603457Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aMsukaita1_5
通过临时密码登录MySQL命令行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@centos8 mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 21 Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, 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>
更改root账号的密码:
1 2
alter user root@localhost identified by 'qszxD@123'; Query OK, 0 rows affected (0.00 sec)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'qszxD@123'; CREATE USER 'root'@'%' IDENTIFIED BY 'qszxD@123'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;