作者:王先生 | 来源:互联网 | 2023-09-15 16:39
摘要:
下文讲述linux操作系统下查看MySQL服务是否开启的方法分享,如下所示;
MySQL数据库服务器是linux中应用最广泛的服务之一,下文将讲述检测MySQL数据库是否对外提供服务的方法分享,如下所示:
实现思路:
方式1:查看是否存在mysqld进程
ps -ef |grep mysqld
方式2:查看是否存在mysqld进程
ps -aux|grep mysqld
方式3:查看ysqld的状态
service mysqld status
方式4:查看mysql的状态
service mysql status
例:
[root@**** mySqlBack]# ps -ef|grep mysqld
mysql 14457 20949 0 Sep09 ? 00:04:41 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var ***********
root 17671 17627 0 09:49 pts/0 00:00:00 grep mysqld
root 20949 1 0 Sep04 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/*********.pid
[root@**** mySqlBack]# ps -aux|grep mysql
mysql 14457 0.4 2.3 591868 23788 ? Sl Sep09 4:41 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var
root 17677 0.0 0.0 103320 844 pts/0 S+ 09:49 0:00 grep mysql
root 20949 0.0 0.0 11340 240 ? S Sep04 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/**********.pid
[root@***** mySqlBack]# service mysqld status
MySQL running (14457) [ OK ]