Как убить mysql с помощью движущегося pid

3820
icicleking

У меня есть несколько экземпляров MySQL, работающих на OSX 10.10. /usr/local/mysql/bin/mysqld stopвыкладывает кучу предупреждений и ошибок, я не уверен, стоит ли им делиться. Вот первая ошибка. 16164 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.Запуск mysql_upgrade завершился неудачно.

Запуск ps aux | grep mysqlрезультатов в:

clayton 16179 0.0 0.0 2423356 228 s000 R+ 10:58AM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql _mysql 15599 0.0 0.3 3070756 24508 ?? S 10:22AM 0:01.64 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/Beast.local.err --pid-file=/usr/local/mysql/data/Beast.local.pid root 15514 0.0 0.0 2452828 876 ?? Ss 10:22AM 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql 

Я пытался убить процессы sudo kill -15 16179 15599 15514, но мой пользовательский процесс pid меняется. kill: 16179: No such process, Если я делаю ps aux | grep mysqlнеоднократно, pid первого процесса, принадлежащего Клейтону, каждый раз подпрыгивает на 10.

Итак, затем я попытался выгрузить MySQL с помощью launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plistи в launchctl unload /Library/LaunchDaemons/com.mysql.mysql.plistрезультате Could not find specified service.

Тьфу. Я определенно озадачен и не уверен, как поступить. Какие-либо предложения?

0

2 ответа на вопрос

0
kenorb

The process probably is probably respawning each time when you try to kill it.

You can always try to use pgrep and kill them at one go, e.g.:

kill $(pgrep mysql) 

But I think the solution would be to find the source where it's get restarted each time, so try checking list of your running/system daemons by using launchctl:

sudo launchctl list 

Then unload as described in: How do you stop MySQL on a Mac OS install?

If you've the problem with:

[ERROR] Can't open the mysql.plugin table.

probably you're running it wrong, by not specifying the right mysql data directories. So maybe it's worth to load them again via launchctl, check how they were run before, or locate your configuration file and double check the configuration, or you've the wrong permissions set-up.

Here is sample syntax how you can run it manually:

mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/var/db/mysql --datadir=/var/db/mysql --plugin-dir=/var/db/mysql/lib/plugin --user=mysql --tmpdir=/tmp/mysql/tmpdir --log-error=/var/log/mysql_error_log.err --pid-file=/tmp/mysql/mysql.pid --socket=/tmp/mysql/mysql.sock --port=3306 

When using MAMP, the command-line parameters looks like:

/Applications/MAMP/Library/bin/mysqld --defaults-file=/Applications/MAMP/tmp/mysql/my.cnf --basedir=/Applications/MAMP/Library --datadir=/Library/Application Support/appsolute/MAMP PRO/db/mysql --plugin-dir=/Applications/MAMP/Library/lib/plugin --user=mysql --tmpdir=/Applications/MAMP/tmp/mysql/tmpdir --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmp/mysql/mysql.sock --port=3306 
0
s1ns3nt

That first line you're seeing is the ps aux | grep mysql command that you're (re-)running each time, so not one to worry about.

You should be able to kill the mysql process by name if you use sudo pkill mysql.