mysql process cannot be stopped
Asked Answered
C

7

31

I have recently installed 5.5.28-29.2 Percona Server (GPL), Release 29.2 in a Ubuntu 12.04 OS Desktop. I have tried to stop the server using different methods:

- sudo /etc/init.d/mysql stop
- sudo kill -9 pid
- mysqladmin -u root -p shutdown

All this methods stop the process, however it starts up automatically after it dies. I have checked syslog (/var/log/syslog/) and always shows me the next trace:

Jan  4 17:50:44 kernel: [ 1915.494219] init: mysql main process (17311) killed by KILL signal
Jan  4 17:50:44 kernel: [ 1915.494245] init: mysql main process ended, respawning
Jan  4 17:50:44 kernel: [ 1915.500025] type=1400 audit(1357318244.557:48): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=18458 comm="apparmor_parser"
Jan  4 17:50:46 /etc/mysql/debian-start[18501]: Upgrading MySQL tables if necessary.
Jan  4 17:50:46 /etc/mysql/debian-start[18504]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
Jan  4 17:50:46 /etc/mysql/debian-start[18504]: Looking for 'mysql' as: /usr/bin/mysql
Jan  4 17:50:46 /etc/mysql/debian-start[18504]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Jan  4 17:50:46 /etc/mysql/debian-start[18504]: This installation of MySQL is already upgraded to 5.5.28, use --force if you still need to run mysql_upgrade
Jan  4 17:50:46 /etc/mysql/debian-start[18515]: Checking for insecure root accounts.
Jan  4 17:50:46 /etc/mysql/debian-start[18520]: Triggering myisam-recover for all MyISAM tables

Do you know the reason why the process restarts automatically ? Thank you in advance!!

Callison answered 4/1, 2013 at 16:58 Comment(0)
U
60

I was having this exact same problem. Running the kill command would kill the process, but in my case it would keep popping up again under a different process ID.

The only way I could figure out how to stop it for good was this:

sudo stop mysql

Source: http://www.itfromscratch.com/how-to-stop-the-percona-mysql-server/

Uzzial answered 11/4, 2013 at 23:34 Comment(6)
What about sudo stop mysqld?Uzzial
Output: stop: Unknown job: mysqldTitrant
What about sudo /etc/init.d/mysql stop?Uzzial
I was also having the exact same problem and your solution did the trick Server version: 5.5.38-0ubuntu0.14.04.1Cowage
@The New Guy I tried sudo /etc/init.d/mysqld stop instead. Didn't work.Increment
What about sudo service mysql stop?Uzzial
M
32

Using sudo service mysql stop worked for me.

Mcmillon answered 27/1, 2014 at 13:5 Comment(1)
The main issue is the service flag in ubuntu, kill -9 or stop would do the trick with any other distro. You have to look into the mysql log. It must say at the bottom: /[path]/mysqld: Shutdown complete, otherwise your daemon is up. You can check it live through: tail -f /[path]/name.log. Great answer.Lithograph
D
18

Want to kill all mysql instances? Try as root:

 pkill mysqld;
Deb answered 4/1, 2013 at 17:2 Comment(1)
I have also tried to kill all instances with pkill but it still starts up. Thank youCallison
K
6

I'm using Homebrew on Mac OS. brew services stop mysql did not work for me, but sudo brew services stop mysql did.

Kalfas answered 25/10, 2017 at 12:41 Comment(0)
R
2

I'm going to guess here, but mysqld might be started via the mysql_safe init script, which will restart the server.

Rorrys answered 4/1, 2013 at 17:1 Comment(1)
You are right, mysqld is being started via mysql_safe init script. However I think that if I use /etc/init.d/mysql stop the server shouldn't restart automatically. Thank youCallison
P
2

For those looking at this years after the fact, I had a similar issue and just solved it.

Seems there was a second init script called orig_mysql.conf that existed in the /etc/init directory along with the mysql.conf file. This caused upstart to start two instances and apparently it got confused when one was ended. As such a continuous respawning took place.

My solution:

  1. Stop mysql via upstart if possible: service mysql stop
  2. REMOVE one of the conf files (I removed /etc/init/orig_mysql.conf). Then restart init using: telinit u
  3. Kill off any remaining mysqld processes manually.

Once you confirm you have no mysqld processes running and that they are not respawning any longer, restart mysql with service mysql start.

Hope this helps someone. It took me two years to solve this.

Procne answered 27/2, 2016 at 2:57 Comment(1)
Thanks ! It helped.Intaglio
A
0

This might not apply to this particular problem but here it goes anyways. I checked the error log ("/var/log/mysql/error.log") and saw that "explicit_defaults_for_timestamp=TRUE" was causing an error ("Unknown variable"). So I removed it from my.cnf ("/etc/mysql/my.cnf"), and ran "sudo start mysql" and it was back up and running. I hope this helps as well!

Armrest answered 16/2, 2016 at 3:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.