Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I run sudo kill -9 [PID] with the proper process ID, the process stops but then is restarted and has a new PID. I'm trying to kill the mysqld process.

How can I mimic the Activity Monitor in killing a process? In the Activity Monitor, when you press "Quit Process", the process permanently stops running, it is totally terminated. I figure that kill will do the same thing right?

I had both the Activity Monitor and the terminal next to each other to see if the command works, but every time I do sudo kill -9 [PID], the process in Activity monitor doesn't go away, it just refreshes with a new PID.

So... how do I kill the mysqld process via the terminal?

share|improve this question

migrated from stackoverflow.com Jul 2 '10 at 16:48

This question came from our site for professional and enthusiast programmers.

    
I did it from the activity monitor because the 'kill' command was not recognising the PID. Again unlike your case my mysqld did not restart as soon as I killed it from the Activity monitor. –  yoosafinpace Sep 28 '13 at 13:46

3 Answers 3

What process are you trying to kill? Some processes in Mac OS X (e.g., the Dock, some system processes) automatically respawn if they're killed.

share|improve this answer
    
I'm trying to kill the mysqld process –  Hristo Jul 2 '10 at 16:43
    
Probably managed by launchd, then, which will restart it if the process dies. –  mipadi Jul 2 '10 at 17:25

The process you are killing is probably being managed by launchd, the proper way to stop it and have it not restart is to use launchctl unload <path to plist>. The plist that controls that process is in either /Library/LaunchDaemons or /System/Library/LaunchDaemons. If it is a system process and not one of your own, then you will probably have to use sudo to get launchctl to work as desired.

A better way try and stop it might be;

${MYSQL_HOME}/bin/mysqladmin -u root -proot shutdown > /dev/null 2>&1
share|improve this answer
    
I'm trying to kill the mysqld process. I'm not sure if that is part of LaunchDaemons... but the following command is the correct way to stop the server from running sudo /usr/local/mysql/support-files/mysql.server stop but I'm having problems with that, so I'm trying to kill the process directly. –  Hristo Jul 2 '10 at 16:44
1  
if it is being restated after kill -9 the launchd is probably involved, even if indirectly. you can tell by using launchctl list –  Jarrod Roberson Jul 2 '10 at 16:56
    
the list doesn't have "mysql" in it. I will try your command up top. –  Hristo Jul 2 '10 at 17:02
    
can you explain what the --defaults-file and /dev/null parts mean? –  Hristo Jul 2 '10 at 17:03
    
Redirect STDOUT and STDERR to /dev/null. –  Hello71 Jul 2 '10 at 17:56
up vote 4 down vote accepted

I tried to kill the process by sending it the TERM signal, and that worked. The command was:

sudo kill -15 {PID}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.