linux的mysql启动命令参数,linux中mysql启动服务命令

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

linux的mysql启动服务命令

linux的mysql启动服务命令1:使用mysqld启动、关闭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.

如果mysql是rpm方式安装的话,mysqld位于/usr/sbin下,如果mysql是二进制安装的话,mysqld则位于bin目录下面。

[[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

linux的mysql启动服务命令2:使用mysqld_safe启动、关闭mysql服务

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

linux的mysql启动服务命令3:使用mysql.server启动、关闭mysql服务

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

shutting down mysql..[ ok ]

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

starting mysql..[ ok ]

[[email protected] mysql]#

mysql.server其实也是一个脚本,它通过调用msqld_safe来启动、关闭mysql服务。部分脚本脚本如下

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

#!/bin/sh

# 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

linux的mysql启动服务命令4:使用mysqld_multi启动、关闭mysql服务

当服务器上运行了多个mysql实例时,mysqld_multi是一个非常棒的管理mysql服务器的工具。当然在使用前,你必须提前做配置

[[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

其实如果你对service比较熟悉的话,就会知道运行上面命令,其实是service命令去找/etc/init.d下的相关的mysql脚本去执行启动、关闭动作。

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

mysql mysql.server

[[email protected] init.d]#

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

如果你非常了解方法5,那么就多了这么一个启动数据库的方式。其实/etc/init.d/mysql也是一个脚本,它调用mysqld_safe脚本来启动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]#

6:使用mysqladmin关闭数据库

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

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值