systemctl status mysql
时间: 2023-11-08 17:06:02 浏览: 88
这个命令用于查看 MySQL 服务的状态,包括是否在运行、最近的启动时间、运行时间等信息。可以在终端中输入该命令进行查看。例如:
```
systemctl status mysql
```
如果 MySQL 服务正在运行,则会显示:
```
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-10-08 15:38:32 CEST; 2 days ago
Main PID: 1194 (mysqld)
Tasks: 38 (limit: 4915)
CGroup: /system.slice/mysql.service
└─1194 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Oct 08 15:38:31 ubuntu systemd[1]: Starting MySQL Community Server...
Oct 08 15:38:32 ubuntu systemd[1]: Started MySQL Community Server.
```
如果 MySQL 服务没有运行,则会显示:
```
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2021-10-08 15:38:32 CEST; 2 days ago
Main PID: 1194 (code=exited, status=0/SUCCESS)
Oct 08 15:38:31 ubuntu systemd[1]: Starting MySQL Community Server...
Oct 08 15:38:32 ubuntu systemd[1]: Started MySQL Community Server.
```
可以根据这些信息来判断 MySQL 服务是否正常运行。
阅读全文