On the 'mysqlinstalldb' command, there needs to be a space between the 'whoami' and the '--basedir' - for me it was a cut&paste gotcha. Otherwise, this was a great help in removing a munged installation, because the filesystem locations seem to be different for each Mac OS and this is the only one I found for Mavericks that pointed me to /usr/local/var/mysql, where all the 'bad' stuff was hiding.
Thank you for this. Between the teams I work with and people wanting to get into the backend of my laptop, my files were all weirded out. This set everything straight, and I was able to get MySql running again!
If anyone else gets errors like this: [Warning] Can't create test file /usr/local/var/mysql/whoami.lower-test [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode [ERROR] InnoDB: The system tablespace must be writable! [ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. [ERROR] Unknown/unsupported storage engine: InnoDB [ERROR] Aborting
Fix permissions using these 2 commands: sudo chown -R whoami:staff /usr/local sudo chmod u+rwX /usr/local
Then pick up with the instructions after brew install mysql.
Very helpful. Working through teamtreehouse course and installed a second instance of mysql. mysql workbench was looking at one instance while the cmd line was seeing another. This cleared out the crap and now all are on the same install.
I spent hours trying to fix my broken install. I finally gave up and followed your guide to completely remove and re-install.
I modified it a bit, since I'm using mariadb, but otherwise perfect match for my needs.
I just made an account to thank you: thank you for writing this. I've been going through a Laracast video tutorial, somehow completely messed up my mysql installation, and was absurdly lost. This is a godsend. Thank you.
After running into the following errors (relatively common, from what I can tell), this was the correct resolution to my issue.
Errors this resolved:
error 2002 (hy000): can't connect to local mysql server through socket '/tmp/mysql.sock'
mysql_install_db is deprecated. Please consider switching to mysqld --initialize
-bash: mysql_install_db --verbose --user=root --basedir=/usr/local/opt/mysql --datadir=/usr/local/var/mysql --tmpdir=/tmp: No such file or directory
Spent half a day trying to resolve "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)" on MacOS Catalina.
Following these steps resolved the issue and mysql is now running and accessible.