在 CentOS 上查看 MySQL 状态,常用的方法有以下几种:
systemctl status mysqld
或(某些版本叫 mysql)
systemctl status mysql
说明:
active (running) 表示正在运行inactive (dead) 表示已停止启动 / 停止 / 重启:
systemctl start mysqld
systemctl stop mysqld
systemctl restart mysqld
service mysqld status
或
service mysql status
ps -ef | grep mysqld
或
pgrep mysqld
netstat -tunlp | grep 3306
或
ss -tunlp | grep 3306
mysql -u root -p
登录后执行:
SHOW STATUS;
或查看简要状态:
STATUS;
日志一般位置:
/var/log/mysqld.log
查看:
tail -f /var/log/mysqld.log
如果你是想 确认 MySQL 是否正常运行,systemctl status mysqld 是最直接的方式。
如果你遇到具体报错,可以把输出贴出来,我可以帮你分析。