您的位置:首页 > 运维架构 > Linux

Linux平台下启动和关闭MySQ服务

2015-05-07 01:43 267 查看
在Linux平台下,可以采用如下命令查看MySQL服务的状态:

[root@localhost ~]# netstat -nlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 2182/./hpiod

tcp 0 0 0.0.0.0:5989 0.0.0.0:* LISTEN 2611/cimservermain

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2369/mysqld

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1833/portmap

tcp 0 0 0.0.0.0:784 0.0.0.0:* LISTEN 1874/rpc.statd

...

[root@localhost ~]#

其中端口号3306是MySQL服务器监听端口;

启动和关闭MySQL有两种方式

1)命令式方式

root@localhost sbin]# cd /usr/bin/

[root@localhost bin]# ./mysqld_safe &


[1] 12788

[root@localhost bin]# 150507 01:25:46 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.

150507 01:25:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@localhost bin]# mysqladmin -u root -p shutdown

Enter password:

150507 01:26:48 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

[1]+ Done ./mysqld_safe

[root@localhost bin]#

2)服务的方式

[root@localhost bin]# service mysql start

Starting MySQL.. [ OK ]

[root@localhost bin]# service mysql restart

Shutting down MySQL.. [ OK ]

Starting MySQL.. [ OK ]

[root@localhost bin]# service mysql stop

Shutting down MySQL.. [ OK ]

[root@localhost bin]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: