10

Background: I've just updated OS X to Mavericks, then I removed brew(and everything I installed via homebrew) using:rm -rf /usr/local and began to reinstall everything.

After brew install mysql, I tried:

unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

But I got:

mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Installing MySQL system tables...2014-02-12 16:43:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-02-12 16:43:45 2358 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-02-12 16:43:45 2358 [Note] InnoDB: The InnoDB memory heap is disabled
2014-02-12 16:43:45 2358 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-02-12 16:43:45 2358 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-02-12 16:43:45 2358 [Note] InnoDB: Using CPU crc32 instructions
2014-02-12 16:43:45 2358 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-02-12 16:43:45 2358 [Note] InnoDB: Completed initialization of buffer pool
2014-02-12 16:43:45 2358 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
2014-02-12 16:43:45 2358 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2014-02-12 16:43:45 2358 [Note] InnoDB: Retrying to lock the first data file
2014-02-12 16:43:46 2358 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
2014-02-12 16:43:46 2358 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

And I got totally lost, and started googling, I only fond this, which seems to be helpful: http://blog.tiagocarvalho.pt/2014/01/mac-os-x-mysql-problems.html

After read that post, still did not get a clear picture, but what in my mind was to (according to that post): FIRST: kill -9 (the mysql PID) and THEN (I think) I should be able to try mysql_install_db again.

So I tried, the ps xua | grep mysql showed:

4683   0.0  0.0  2442000    624 s001  S+    7:39下午   0:00.01 grep mysql
4547   0.0  3.3  3080024  68276   ??  S     7:18下午   0:00.98 /usr/local/Cellar/mysql/5.6.16/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.16 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.16/lib/plugin --log-error=/usr/local/var/mysql/UU.local.err --pid-file=/usr/local/var/mysql/UU.local.pid
4476   0.0  0.0  2436436    808   ??  S     7:18下午   0:00.02 /bin/sh /usr/local/bin/mysqld_safe

BUT, after kill -9 4547 and kill -9 4476, they showed up again with two different PID...

I don't know what is going on... Any hint?

ALSO, if I do mysql.server stop, then mysql.server status I'll find it restarts...

iceX
  • 443
  • 1
  • 4
  • 11

2 Answers2

10

Oops... I think I've found it...

I just need to launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist.

I mean, I did not unload it before rm -rf /usr/local, so after I reinstall brew and mysql, it will automatically starts, which prevents me from doing mysql_install_db...

btw, I found this link very helpful as well: How do you stop MySQL on a Mac OS install?

Community
  • 1
  • 1
iceX
  • 443
  • 1
  • 4
  • 11
  • 1
    hmmm... I was having this exact same problem, but I don't seem to *have* a homebrew entry under /Library/LaunchAgents. If I get this solved, I'll add another answer, in case someone else has the same issue. (PS -- I have no idea why someone would have downvoted the question. It's on-topic, detailed, and shows research effort.) – LindaJeanne Aug 14 '15 at 13:21
  • thank you so much for that unload command... i had to murder and reinstall mysql and this error was making me nuts – caro Jan 01 '17 at 16:31
0

NOTE: I had installed using homebrew. The location of mysql files may depend on whether you used brew or package installer.

I first tried killing the processes by listing all mysql processes - ps aux | grep mysql. That didn't work. Turns out it still restarted, weirdly!

So i listed the files here -> ls /usr/local/var/mysql. Found three pid files. Got rid of them rm -rf <my-machine>.pid rm -rf <my-machine.local.pid> rm -rf mysqld_safe.pid

That helped shut them down.

In your case, these files may lie in /usr/local/mysql/var, or elsewhere. Just look!

Goodluck!

naivecitizen
  • 141
  • 1
  • 5