9

I used ps ax | grep mysql to check whether mysql process exists and i found

5323 s000 S+ 0:00.00 grep mysql .

I would like to kill the process but the number changed automatically.

When i enter ps ax | grep mysql, the content changed like

5507 s000 S+ 0:00.00 grep mysql

BTW, i have tried the way to deleted mysql that is the most popular way on the internet. But the mysql process still on my computer.

Anyone could give me a hint would be highly appreciated.

Peter Tsung
  • 915
  • 2
  • 10
  • 20
  • 1
    if you are install mysql via brew, you can use `mysql.server stop` to stop the process. – Enix Mar 18 '17 at 15:22

2 Answers2

11

just did it. I tried: 1) get pid

netstat -vanp tcp | grep 3306

or

ps ax | grep mysql

2) sudo kill -9 [pid] It seems that I killed it right? but wait... when show mysql pid again, it comes back again with a different pid. Then I remember mysql in system preferences. Press the icon, and press stop server button. SUCCESS

EDIT: it is here

bing searching results

Tiina
  • 4,285
  • 7
  • 44
  • 73
1

Your output shows the grep process searching for "mysql" in the result from ps. That means, you just see the process showing you the processes you search for.

mysql is not running here, so you don't get it listed.

And you can't kill that process because it has finished as soon as you return to the shell. The next time you issue the same command, a new ps process spawns and a new grep process spawns with another pid than the one before.

Psi
  • 6,387
  • 3
  • 16
  • 26
  • so could i understand your words like mysql process doesn't run my computer anymore – Peter Tsung Mar 18 '17 at 15:16
  • Correct. See my second paragraph – Psi Mar 18 '17 at 15:18
  • 1
    this is not a "problem" of `ps`, neither of `grep`. It's just the way it works: `ps` always shows _all_ processes running at that moment (including itself and `grep` which you started together with `ps`). And grep is just something that filters text. you connect them both with the `|` pipe, so the output of `ps` becomes the input of `grep`. And that just filters out every line that is not matched. So in the end, it finds at least itself (because `grep mysql` matches `"mysql"`) – Psi Mar 18 '17 at 15:30