mysqld_safe之三言两语
today,one buddy in IMG wechat group 2 asked "why i've installed the MySQL 5.7 on linux server,but there's no mysqld_safe command at all?"so,here i'd like to post this article to say something about it.first of all,let's see the command parameter and usage:
#mysqld_safe --help
Usage: /usr/local/mysql/bin/mysqld_safe [OPTIONS]
The following options may be given as the first argument:
--no-defaults Don't read the system defaults file
--defaults-file=FILE Use the specified defaults file
--defaults-extra-file=FILE Also use defaults from the specified file Other options:
--ledir=DIRECTORY Look for mysqld in the specified directory
--open-files-limit=LIMIT Limit the number of open files
--core-file-size=LIMIT Limit core files to the specified size
--timezone=TZ Set the system timezone
--malloc-lib=LIB Preload shared library LIB if available
--mysqld=FILE Use the specified file as mysqld
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
--nice=NICE Set the scheduling priority of mysqld
--plugin-dir=DIR Plugins are under DIR or DIR/VERSION, if
VERSION is given
--skip-kill-mysqld Don't try to kill stray mysqld processes
--syslog Log messages to syslog with 'logger'
--skip-syslog Log messages to error log (default)
--syslog-tag=TAG Pass -t "mysqld-TAG" to 'logger'
--mysqld-safe-log- TYPE must be one of UTC (ISO UTC),
timestamps=TYPE system (ISO local time), hyphen
(hyphenated date a la mysqld 5.6), legacy
(legacy non-ISO mysqld_safe timestamps) All other options are passed to the mysqld program. [root@zlm3 :: /data/mysql/mysql3306]
#
the most simplest usage of mysqld_safe way is to just use '--defaults-file' to specify which "my.cnf" you want to use,just like:
[root@zlm3 :: /usr/local/mysql/bin]
#pkill mysqld [root@zlm3 :: /usr/local/mysql/bin]
#ps aux|grep mysqld
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /usr/local/mysql/bin]
#mysqld_safe --defaults-file=/data/mysql/mysql3306/my.cnf &
[] [root@zlm3 :: /usr/local/mysql/bin]
#--04T05::.758814Z mysqld_safe Logging to '/data/mysql/mysql3306/data/error.log'.
--04T05::.786306Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql3306/data
^C [root@zlm3 :: /usr/local/mysql/bin]
#ps aux|grep mysqld
root 0.1 0.1 pts/ S : : /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3306/my.cnf
mysql 1.0 17.4 pts/ Sl : : /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=error.log --open-files-limit= --pid-file=mysql.pid --socket=/tmp/mysql3306.sock --port=
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /usr/local/mysql/bin]
#
here we can see,there're two processes running,one is mysqld_safe,another one is the mysqld.even if you use "kill -9 7328" to stop the mysqld process,but subsequently you'll find that the mysqld will startup again soon,unless you kill mysqld process by using "pkill mysqld" as below:
[root@zlm3 :: /usr/local/mysql/bin]
#kill - [root@zlm3 :: /usr/local/mysql/bin]
#/usr/local/mysql/bin/mysqld_safe: line : Killed nohup /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=error.log --open-files-limit= --pid-file=mysql.pid --socket=/tmp/mysql3306.sock --port= < /dev/null > /dev/null >&
--04T05::.076914Z mysqld_safe Number of processes running now:
--04T05::.083092Z mysqld_safe mysqld restarted
^C [root@zlm3 :: /usr/local/mysql/bin]
#ps aux|grep mysqld
root 0.0 0.1 pts/ S : : /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3306/my.cnf
mysql 2.4 17.7 pts/ Sl : : /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=error.log --open-files-limit= --pid-file=mysql.pid --socket=/tmp/mysql3306.sock --port=
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /usr/local/mysql/bin]
#pkill mysqld [root@zlm3 :: /usr/local/mysql/bin]
#--04T05::.957789Z mysqld_safe mysqld from pid file /data/mysql/mysql3306/data/mysql.pid ended
^C
[]+ Done mysqld_safe --defaults-file=/data/mysql/mysql3306/my.cnf [root@zlm3 :: /usr/local/mysql/bin]
#ps aux|grep mysqld
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /usr/local/mysql/bin]
#
For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, mysqld_safe is not installed because it is unnecessary. For more information, see Section 2.5.9, “Managing MySQL Server with systemd”.
therefore,if you want the mysqld_safe feature,i rather recommend you to install MySQL server with binary distribution instead of rpm distribution.
4.3.2 mysqld_safe — MySQL Server Startup Script
mysqld_safe is the recommended way to start a mysqld server on Unix. mysqld_safe adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log. A description of error logging is given later in this section.
来源: https://dev.mysql.com/doc/refman/8.0/en/mysqld-safe.html
summary:
another buddy in zst techique wechat group said that it will be messy in troubleshooting while using mysqld_safe to startup mysqld,'cause in some case,the mysqld_safe may lead to the ceaseless restarting of mysqld.furthermore,it may destroy the evidences and logs which can be diagnosted by DBAs.anyhow,in my opinion it depends:
- if the bussines continuity is the first thing you need to consider,i recommend to use mysqld_safe method.
- if your monitor system is strong enough or the application on the MySQL server is not so important such as enterprise management system,BBS system,i recommend to use mysqld method.
mysqld_safe之三言两语的更多相关文章
- 执行mysqld_safe报错:mysqld does not exist or is not executable
执行mysqld_safe报错: [root@edu data]# /usr/local/mysql5.7/bin/mysqld_safe --user=mysql160427 12:41:28 my ...
- 三言两语之微信小程序开发初体验(1)
一.前情 直接切入主题,微信发布了小程序,前端开发者表示,如果不会微信小程序的开发感觉就跟不上时代了,先解答几个容易出现歧义的问题 小程序就叫小程序,不叫应用号,因为apple不准,哈哈 小程序是 ...
- 关于Mysql错误:./bin/mysqld_safe --user=mysql& [1] 32710 121003 16:40:22 mysqld_safe Logging to '/var/log/mysqld.log'. 121003 16:40:22 mysqld_s
[root@www]# ./bin/mysqld_safe --user=mysql&[1] 32710[root@www]# 121003 16:40:22 mysqld_safe Logg ...
- mysqld_safe启动报错 mysqld_safe The file /usr/local/mysql/bin/mysqld does not exist or is not executable
报错(如下),但是使用mysqld直接启动没有问题. 150718 00:03:38 mysqld_safe Logging to '/var/log/mysqld.log'. 150718 00:0 ...
- Error with mysqld_safe
出处:http://bugs.mysql.com/bug.php?id=18403 Description: - I downloaded the binary file “Standard 5.0. ...
- 启动mysql错误解决方案,学会查看错误日志:mysql.sock丢失,mysqld_safe启动报错
本人还是个菜鸟,下面是我的经验之谈,能解决一些问题,有不对的地方,敬请斧正. 我的是CentOS6.3+MySQL5.1.57. 重启了一次服务器后,使用> mysql -u root -p登陆 ...
- [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 160913 02:11:21 mysqld_safe mysqld from pid file /tmp/mysql.pid ended
-- :: [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 -- :: [Warning] InnoDB: New ...
- 【国庆】记一次mysqld_safe引发mysql进程故障
今天是举国欢庆的日子,但是Mariadb密码忘记了,于是巴拉巴拉的执行"mysqld_safe --skip-grant-tables &"这个神技能,打算跳过密码验证,直 ...
- Linux下忘记MySQL密码的解决方法和输入mysqld_safe --skip-grant-tables &后无法进入MySQL的解决方法
在Linux下忘记MySQL密码后我们可以通过一个mysql的参数--skip-grant-tables &轻松解决这个问题 亲测在CentOS有效 其中 --skip-grant-table ...
随机推荐
- Winform访问本地SQLServer数据库文件
Winform访问本地SQLServer数据库文件 1.项目中添加config配置,如下: <configuration> <connectionStrings> <ad ...
- UTF-8文件编码格式中有无签名问题汇总(BOM)
UTF-8签名(UTF-8 signature)也叫做BOM(Byte order Mark),是UTF编码方案里用于标识编码的标准标记.如果多个文件设置了签名,在二进制流中就会包含多个UTF-8签名 ...
- webpack2-webpack.config.js配置
写在前面: 了解更多:https://github.com/miaowwwww/webpack-learn 贴一个webpack.ocnfig.js 的配置属性表 一.代码分割: 1.插件 Comm ...
- Java—IO流 字符流
java的文本(char)是16位无符号整数,是字符的unicode编码(双字节编码). 文件是byte byte byte ... 的数据序列. 文本文件是文本(char)序列按照某种编码方案(uf ...
- Windows10 IIS配置PHP运行环境(原创)
在Windows 10/8 的IIS(8.0)中搭建PHP运行环境: 如果解决了您的问题,文章底部点击下关注,做原创内容不容易,谢谢.转载请注明出处 PS:顺便推荐下自己写的,开源PHP极速后台开发框 ...
- 从Event Loop谈JS的运行机制
这里主要是结合Event Loop来谈JS代码是如何运行的. 事件循环对于我们平时开发可以说是特别重要,可以让我们写出更好的代码. 到这里相信我们已经知道了JS引擎是单线程,而且这里会用到前面说的的几 ...
- mysql5.7
原文 http://imysql.com/2015/07/08/mysql-57-new-feature-part-3.shtml 主题 MySQL 本文将和大家一起分享下5.7的新特性,不过我们要 ...
- July 07th 2017 Week 27th Friday
Learn wisdom by the follies of others. 要从别人的愚行中学到智慧. How to become smart or what characters should a ...
- react开发中如何使用require.ensure加载es6风格的组件
其实用的babel,在浏览器端就应该可以加载,之前少了个default: require.ensure([],(require) => { let A = require('./a.js').d ...
- UVa 10375 - Choose and divide(唯一分解定理)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...