linux下使用相关命令可以直接启动mysql服务,下面由秋天网 Qiutian.ZqNF.Com小编为大家整理了linux下mysql启动服务命令的相关知识,希望对大家有帮助!



mysqld是mysql的守护进程,我们可以用mysqld来启动、关闭mysql服务,关于mysqld, mysql 5.6官方介绍资料如下所示:

mysqld, also known as mysql server, is the main program that does most of the work in a mysql installation. mysql server manages access to the mysql data directory that contains databases and tables. the data directory is also the default location for other information such as log files and status files.

when mysql server starts, it listens for network connections from client programs and manages access to databases on behalf of those clients.

the mysqld program has many options that can be specified at startup. for a complete list of options, run this command:

shell> mysqld --verbose --help

mysql server also has a set of system variables that affect its operation as it runs. system variables can be set at server startup, and many of them can be changed at runtime to effect dynamic server reconfiguration. mysql server also has a set of status variables that provide information about its operation. you can monitor these status variables to access runtime performance characteristics.


[[email protected] ~]# whereis mysqld

mysqld: /usr/sbin/mysqld /usr/share/man/man8/mysqld.8.gz

[[email protected] ~]# /usr/sbin/mysqld stop

2016-06-27 14:52:54 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-06-27 14:52:54 9315 [error] fatal error: please read "security" section of the manual to find out how to run mysqld as root!

2016-06-27 14:52:54 9315 [error] aborting

2016-06-27 14:52:54 9315 [note] binlog end

2016-06-27 14:52:54 9315 [note] /usr/sbin/mysqld: shutdown complete

[[email protected] ~]# /usr/sbin/mysqld start

2016-06-27 14:52:59 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-06-27 14:52:59 9316 [error] fatal error: please read "security" section of the manual to find out how to run mysqld as root!

2016-06-27 14:52:59 9316 [error] aborting

2016-06-27 14:52:59 9316 [note] binlog end

2016-06-27 14:52:59 9316 [note] /usr/sbin/mysqld: shutdown complete


很多时候,人们会纠结mysqld与mysqld_safe的区别. 其实mysqld_safe是一个脚本,一个非常安全的启动、关闭mysql服务的脚本。它实际上也是调用mysqld来启动、关闭mysql服务。关于mysqld_safe,可以参考官方文档mysqld_safe — mysql server startup


[[email protected] mysql]# ./mysql.server stop

shutting down mysql..[ ok ]

[[email protected] mysql]# ./mysql.server start

starting mysql..[ ok ]

[[email protected] mysql]#


[[email protected] mysql]# more mysql.server


# copyright abandoned 1996 tcx datakonsult ab & monty program kb & detron hb

# this file is public domain and comes with no warranty of any kind

# mysql daemon start/stop .

# usually this is put in /etc/init.d (at least on machines sysv r4 based

# systems) and linked to /etc/rc3.d/s99mysql and /etc/rc0.d/k01mysql.

# when this is done the mysql server will be started when the machine is

# started and shut down when the systems goes down.

# comments to support chkconfig on redhat linux

# chkconfig: 2345 64 36

# deion: a very fast and reliable sql database engine.

# comments to support lsb init conventions

### begin init info

# provides: mysql

# required-start: $local_fs $network $remote_fs

# should-start: ypbind nscd ldap ntpd xntpd

# required-stop: $local_fs $network $remote_fs



[[email protected] mysql]# /usr/bin/mysqld_multi stop 1

[[email protected] mysql]# /usr/bin/mysqld_multi start 1

mysqld_multi is designed to manage several mysqld processes that listen for connections on different unix socket files and tcp/ip ports. it can start or stop servers, or report their current status.

mysqld_multi searches for groups named [mysqldn] in my.cnf (or in the file named by the --defaults-file option). n can be any positive integer. this number is referred to in the following discussion as the option group number, or gnr. group numbers distinguish option groups from one another and are used as arguments tomysqld_multi to specify which servers you want to start, stop, or obtain a status report for. options listed in these groups are the same that you would use in the[mysqld] group used for starting mysqld. (see, for example, section 2.10.5, “starting and stopping mysql automatically”.) however, when using multiple servers, it is necessary that each one use its own value for options such as the unix socket file and tcp/ip port number. for more information on which options must be unique per server in a multiple-server environment, see section 5.6, “running multiple mysql instances on one machine”.

linux的mysql启动服务命令5:使用service 启动、关闭mysql服务

service mysql start

service mysql stop

service mysql restart


[[email protected] init.d]# ls my*

mysql mysql.server

[[email protected] init.d]#

linux的mysql启动服务命令6: 使用/etc/init.d/mysql启动、关闭mysql服务。


[[email protected] bin]# /etc/init.d/mysql start

starting mysql....[ ok ]

[[email protected] bin]# /etc/init.d/mysql stop

shutting down mysql..[ ok ]

[[email protected] bin]#


mysqladmin是一个执行管理操作的客户程序,这个命令可以使用安全模式关闭数据库,但是不能启动数据库。当然它可以停止和启动mysql replication on a slave server

[[email protected] bin]# /usr/bin/mysqladmin -u root -p shutdown

enter password:

  • 0
  • 0
  • 0


  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
©️2022 CSDN 皮肤主题:深蓝海洋 设计师:CSDN官方博客 返回首页
钱包余额 0