# stopping percona - "/etc/init.d/mysql stop" does not stop mysqld\_safe

**URL:** <https://forums.percona.com/t/stopping-percona-etc-init-d-mysql-stop-does-not-stop-mysqld-safe/3113>\
**Category:** Other MySQL® Questions\
**Created:** [November 21, 2013, 11:48am UTC](https://forums.percona.com/t/stopping-percona-etc-init-d-mysql-stop-does-not-stop-mysqld-safe/3113 "2013-11-21T11:48:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Torgerson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/david_torgerson/32/978_2.png) [@David\_Torgerson](https://forums.percona.com/u/David_Torgerson)\
**Post date:** [November 21, 2013, 11:48am UTC](https://forums.percona.com/t/stopping-percona-etc-init-d-mysql-stop-does-not-stop-mysqld-safe/3113/1 "2013-11-21T11:48:14Z")

</div>

We are in the process of switching from mysql 5.5 to percona 5.6 on ubuntu 12.04. When I try to stop mysqld using the init.d script, it appears that mysqld\_safe is not stopped and so it restarts mysqld.

I google’d for similar problems but have only found messages from 2010 and none are relevant. I have looked through the init.d script and it does not appear that there is ever an attempt to kill mysqld\_safe. I have also looked for a setting in mysqld\_safe to disable restarting mysqld but I have not been able to find anything.

Thoughts?

---

<div class="post-metadata">

**Author:** ![David\_Torgerson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/david_torgerson/32/978_2.png) [@David\_Torgerson](https://forums.percona.com/u/David_Torgerson)\
**Post date:** [November 21, 2013, 3:59pm UTC](https://forums.percona.com/t/stopping-percona-etc-init-d-mysql-stop-does-not-stop-mysqld-safe/3113/2 "2013-11-21T15:59:12Z")

</div>

I was able to track down that mysqld\_safe is doing the correct thing. There is a while loop to restart mysql after a failed stop, but the trigger to exit is based on if the pid file still exists for mysqld or not. The /etc/init.d/mysql script does not remove the pid file after a successful stop so msyqld\_safe is always restarting mysql. I am checking into why /etc/init.d/mysql is not removing the PID file. Anyone else run into this?

---

<div class="post-metadata">

**Author:** ![David\_Torgerson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/david_torgerson/32/978_2.png) [@David\_Torgerson](https://forums.percona.com/u/David_Torgerson)\
**Post date:** [November 21, 2013, 4:21pm UTC](https://forums.percona.com/t/stopping-percona-etc-init-d-mysql-stop-does-not-stop-mysqld-safe/3113/3 "2013-11-21T16:21:47Z")

</div>

It appears that the init.d script is not supposed to remove the mysqld pid file. Instead mysqld should clean up it’s own pid upon successful exit. For some reason it was not when the pid file is in the default location (/var/run/mysqld/mysqld.pid). I changed this to have the pid file in /tmp and it appears to be working now.

---

<div class="post-metadata">

**Author:** ![przemek](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/przemek/32/3_2.png) [@przemek](https://forums.percona.com/u/przemek)\
**Post date:** [November 22, 2013, 4:48pm UTC](https://forums.percona.com/t/stopping-percona-etc-init-d-mysql-stop-does-not-stop-mysqld-safe/3113/4 "2013-11-22T16:48:01Z")

</div>

For me, on fresh install of Percona Server 5.6.14 on ubuntu 12.04, the init.d script does start/stop correctly and cleans the pid file. However, the default pid file for me is:  
–pid-file=/var/lib/mysql/ubuntu1204.pid, hence it is owned by mysql user. Make sure the /var/run/mysqld catalog is also owned by mysql, and that should fix the issue. Or just use the same path as datadir.
