ubuntu查看mysql是否启动命令_ubuntu查看Mysql是否已启动
时间: 2023-12-17 17:05:19 浏览: 89
在 Ubuntu 中,可以使用以下命令来查看 MySQL 是否已启动:
```
sudo service mysql status
```
如果 MySQL 正在运行,它将显示类似以下内容的消息:
```
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-09-03 10:00:00 UTC; 1h 15min ago
Main PID: 1234 (mysqld)
Tasks: 33 (limit: 2292)
Memory: 456.0M
CGroup: /system.slice/mysql.service
└─1234 /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 Fri 2021-09-03 09:50:00 UTC; 1h 25min ago
Main PID: 1234 (code=exited, status=0/SUCCESS)
```
此时,你可以使用以下命令来启动 MySQL:
```
sudo service mysql start
```
阅读全文