linux查看mysql是否启动
时间: 2023-09-29 14:03:18 浏览: 137
要查看 MySQL 是否在 Linux 上启动,可以执行以下命令:
```
systemctl status mysql
```
如果 MySQL 正在运行,它将返回类似于以下内容的输出:
```
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-05-10 08:44:12 UTC; 6 days ago
Main PID: 1409 (mysqld)
Tasks: 39 (limit: 4679)
Memory: 327.6M
CGroup: /system.slice/mysql.service
└─1409 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
```
如果 MySQL 没有启动,它将返回类似于以下内容的输出:
```
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2021-05-10 08:43:24 UTC; 6 days ago
Process: 1384 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Main PID: 1384 (code=exited, status=0/SUCCESS)
```
如果 MySQL 没有启动,则可以使用以下命令启动它:
```
systemctl start mysql
```
阅读全文