linux输入 sudo service mysql restart 命令后 怎么知道mysql重启成功了
时间: 2024-05-29 14:10:05 浏览: 125
您可以执行以下命令来检查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 Mon 2021-01-04 13:42:10 UTC; 4s ago
Process: 1234 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 1235 (mysqld)
Tasks: 26 (limit: 2340)
Memory: 107.2M
CGroup: /system.slice/mysql.service
└─1235 /usr/sbin/mysqld
Jan 04 13:42:10 ubuntu systemd[1]: Starting MySQL Community Server...
Jan 04 13:42:10 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 Mon 2021-01-04 13:42:10 UTC; 4s ago
Process: 1234 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Jan 04 13:42:10 ubuntu systemd[1]: Starting MySQL Community Server...
Jan 04 13:42:10 ubuntu systemd[1]: Started MySQL Community Server.
请注意,如果MySQL未运行,您可能需要检查MySQL错误日志以查找原因。错误日志通常位于/var/log/mysql/error.log。
阅读全文