Linux平台MySQL启动关闭方式总结
作者:潇湘隐者 发布时间:[ 2016/7/21 10:30:21 ] 推荐标签:Linux 数据库 MySQL
3:使用mysql.server启动、关闭MySQL服务
[root@localhost mysql]# ./mysql.server stop
Shutting down MySQL..[ OK ]
[root@localhost mysql]# ./mysql.server start
Starting MySQL..[ OK ]
[root@localhost mysql]#
mysql.server其实也是一个脚本,它通过调用msqld_safe来启动、关闭MySQL服务。部分脚本脚本如下
[root@localhost 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 script.
# 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
# description: A very fast and reliable SQL database engine.
# Comments to support LSB init script 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
4:使用mysqld_multi启动、关闭MySQL服务
当服务器上运行了多个MySQL实例时,mysqld_multi是一个非常棒的管理MySQL服务器的工具。当然在使用前,你必须提前做配置
[root@localhost mysql]# /usr/bin/mysqld_multi stop 1
[root@localhost 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”.
5:使用service 启动、关闭MySQL服务
service mysql start
service mysql stop
service mysql restart
其实如果你对service比较熟悉的话,会知道运行上面命令,其实是service命令去找/etc/init.d下的相关的mysql脚本去执行启动、关闭动作。
[root@DB-Server init.d]# ls my*
mysql mysql.server
[root@DB-Server init.d]#
6: 使用/etc/init.d/mysql启动、关闭MySQL服务。
如果你非常了解方法5,那么多了这么一个启动数据库的方式。其实/etc/init.d/mysql也是一个脚本,它调用mysqld_safe脚本来启动MySQL服务。如下所示,你会看到相关代码
[root@DB-Server bin]# /etc/init.d/mysql start
Starting MySQL....[ OK ]
[root@DB-Server bin]# /etc/init.d/mysql stop
Shutting down MySQL..[ OK ]
[root@DB-Server bin]#
7:使用mysqladmin关闭数据库
mysqladmin是一个执行管理操作的客户程序,这个命令可以使用安全模式关闭数据库,但是不能启动数据库。当然它可以停止和启动MySQL replication on a slave server
[root@DB-Server bin]# /usr/bin/mysqladmin -u root -p shutdown
Enter password:
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11热门文章
常见的移动App Bug??崩溃的测试用例设计如何用Jmeter做压力测试QC使用说明APP压力测试入门教程移动app测试中的主要问题jenkins+testng+ant+webdriver持续集成测试使用JMeter进行HTTP负载测试Selenium 2.0 WebDriver 使用指南