ubuntu查看mysql服务
时间: 2023-07-26 09:38:48 浏览: 117
你可以通过以下命令来查看 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 Sat 2021-09-11 11:48:30 UTC; 5min ago
Main PID: 1234 (mysqld)
Tasks: 28 (limit: 946)
Memory: 372.8M
CGroup: /system.slice/mysql.service
└─1234 /usr/sbin/mysqld
```
如果 MySQL 服务未运行,则输出将类似于以下内容:
```
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2021-09-11 11:43:12 UTC; 8min ago
Process: 1234 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Process: 4567 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 1234 (code=exited, status=0/SUCCESS)
```
如果 MySQL 服务未运行,则可以使用以下命令启动它:
```
sudo systemctl start mysql
```
希望对你有帮助!
阅读全文