温馨提示×

centos mysql怎样重启服务

小樊
33
2026-10-14 13:10:09
栏目: 云计算

在 CentOS 上重启 MySQL 服务,根据你使用的 CentOS 版本 和 MySQL/MariaDB 类型,命令会略有不同。


一、CentOS 7 / 8(使用 systemd)

1. 重启 MySQL(Oracle MySQL)

systemctl restart mysqld

2. 重启 MariaDB(CentOS 默认)

systemctl restart mariadb

3. 查看状态

systemctl status mysqld
# 或
systemctl status mariadb

二、CentOS 6 及更早版本(使用 service)

service mysqld restart
# 或
service mariadb restart

三、常见问题

1. 不知道是 MySQL 还是 MariaDB?

mysql -V

或

ps aux | grep mysql

2. 服务名不对?

尝试:

systemctl list-unit-files | grep -i mysql

3. 重启失败如何排查?

journalctl -xe

或查看日志:

cat /var/log/mysqld.log

如果你能告诉我:

  • CentOS 版本(cat /etc/redhat-release)
  • 用的是 MySQL 还是 MariaDB

我可以给你更精确的建议。

0 踩