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]
#
    why will that happen?the consequence is trigged by mysqld_safe which can protect mysqld from killing by some command like "kill -9" accidentally.or in the other case,the mysqld process shuted down by the OS because of some unknowing issue or bug.that will help you to prevent the application from disconnecting the MySQL server when mysqld process down.but why the buddy's MySQL server hasnot the mysqld_safe command?here's the explaination:
 

Note

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.

someone said that mysqld_safe will not be supported in the future release,but what i've seen is the version 8.0 official document is that it still be recommended:
 

 MySQL 8.0 Reference Manual  /  ...  /  mysqld_safe — MySQL Server Startup Script

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之三言两语的更多相关文章

  1. 执行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 ...

  2. 三言两语之微信小程序开发初体验(1)

    一.前情   直接切入主题,微信发布了小程序,前端开发者表示,如果不会微信小程序的开发感觉就跟不上时代了,先解答几个容易出现歧义的问题 小程序就叫小程序,不叫应用号,因为apple不准,哈哈 小程序是 ...

  3. 关于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 ...

  4. 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 ...

  5. Error with mysqld_safe

    出处:http://bugs.mysql.com/bug.php?id=18403 Description: - I downloaded the binary file “Standard 5.0. ...

  6. 启动mysql错误解决方案,学会查看错误日志:mysql.sock丢失,mysqld_safe启动报错

    本人还是个菜鸟,下面是我的经验之谈,能解决一些问题,有不对的地方,敬请斧正. 我的是CentOS6.3+MySQL5.1.57. 重启了一次服务器后,使用> mysql -u root -p登陆 ...

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

  8. 【国庆】记一次mysqld_safe引发mysql进程故障

    今天是举国欢庆的日子,但是Mariadb密码忘记了,于是巴拉巴拉的执行"mysqld_safe --skip-grant-tables &"这个神技能,打算跳过密码验证,直 ...

  9. Linux下忘记MySQL密码的解决方法和输入mysqld_safe --skip-grant-tables &后无法进入MySQL的解决方法

    在Linux下忘记MySQL密码后我们可以通过一个mysql的参数--skip-grant-tables &轻松解决这个问题 亲测在CentOS有效 其中 --skip-grant-table ...

随机推荐

  1. 139.00.004 Git学习-远程仓库之Github

    参考Github官方HelloWorld入门教程 "有了远程仓库,妈妈再也不用担心我的硬盘了."--Git点读机 本章开始介绍Git的杀手级功能之一(注意是之一,也就是后面还有之二 ...

  2. C#网易云音乐播放器

    效果图: •实现教程: 打开VStudio 2015 #新建一个windows界面工程然后按我的界面来添加控件代码如下 namespace NeteaseMuisc { partial class M ...

  3. 第三次Scrum

    1.小组成员 周 斌舒 溢许嘉荣唐 浩黄欣欣廖帅元刘洋江薛思汝 2.小组第三次冲刺完成情况 github仓库小组的第三次任务是完成体系结构环境图和系统原型图.在体系结构设计中,分为上级系统----把目 ...

  4. maven学习(七)后续扩展、资料

    写这几篇博客的来源是 "maven实战 + 网上的博客 + 平时使用的心得 ".记录的都是比较常用的东西,也有一些只做了大概了解.或者干脆直接略过,在这里做一下总结,如果有需要在进 ...

  5. C++的extern关键字

    extern是一个声明,不是一个定义,A模块想应用B模块的一个函数或者变量,A模块包含B模块的头文件,并且在变量或者头文件前,加 extern,虽然编译的时候,找不到模块的定义,但是在连接的时候,会在 ...

  6. 【2D游戏引擎】那些年对游戏对象的思考

    WIP源代码: Github OSC镜像 对象系统以对象为中心,对象系统的最基本设计策略是基于组件的设计.对象系统将尽量避免使用继承方式来拓展游戏对象,恰当的使用Mix-in来来最属性做拓展,单个属性 ...

  7. ADB命令详解及大全( 声明:此文是参考大佬博客所做的笔记!)

    adb是什么? adb的全称为Android Debug Bridge,就是起到调试桥的作用.通过adb我们可以在Eclipse中方面通过DDMS来调试Android程序,说白了就是debug工具.a ...

  8. awk的简单使用

    awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各 ...

  9. phonegap 捕获图片,音频,视屏 api capture

    一. capture Api 简单介绍 capture 对象用于获取视屏,音频和图像,它是一个全局对象,通过 navigator.device.capture 来访问 方法: capture.capt ...

  10. Python小技巧:使用*解包和itertools.product()求笛卡尔积

    [问题] 目前有一字符串s = "['a', 'b'],['c', 'd']",想把它分开成为两个列表: list1 = ['a', 'b'] list2 = ['c', 'd'] ...