I recently tried installing MySQL with homebrew (brew install mysql
) and when I try to run it I get the following error:
ERROR 2002 (HY00
If you are able to see "mysql stopped" when you run below command;
brew services list
and if you are able to start mysql with below command;
mysql server start
this means; mysql is able to start manually, but it doesn't start automatically when the operating system is started. Adding mysql to services will fix this problem. To do so, you can run below command;
brew services start mysql
After that, you may restart your operating system and try connecting to mysql to see if it started automatically. I did the same and stop receiving below error;
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I hope this helps.
I faced the same problem on my mac and solved it, by following the following tutorials
https://mariadb.com/resources/blog/installing-mariadb-10116-mac-os-x-homebrew
But don't forget to kill or uninstall the old version before continuing.
Commands:
brew uninstall mariadb
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - See more at: https://mariadb.com/resources/blog/installing-mariadb-10116-mac-os-x-homebrew#sthash.XQoxRoJp.dpuf
brew doctor
brew update
brew info mariadb
brew install mariadb
mysql_install_db
mysql.server start
I had some directories left from another mysql(8.0) installation, that were not removed.
I solved this by doing the following:
First uninstall mysql
brew uninstall mysql@5.6
Delete the folders/files that were not removed
rm -rf /usr/local/var/mysql
rm /usr/local/etc/my.cnf
Reinstall mysql and link it
brew install mysql@5.6
brew link --force mysql@5.6
Enable and start the service
brew services start mysql@5.6
just to complete this thread. therefore MAMP (PRO) is used pretty often
the path here is
/Applications/MAMP/tmp/mysql/mysql.sock
I had same problem. After trying all these methods without success I did the following:
tail -f the-mysql-or-maria-db-error-file.err
in another console:
brew services restart mariadb
I saw the following error:
"MAC HOMEBREW Crash recovery failed. Either correct the problem (if it's, for example, out of memory error) and restart, or delete tc log and start mysqld with"
So I changed the tc.log
extesion to tc.log.txt
and restart mariadb
brew services restart mariadb
and done!
You'll need to run mysql_install_db
- easiest way is if you're in the install directory:
$ cd /usr/local/Cellar/mysql/<version>/
$ mysql_install_db
Alternatively, you can feed mysql_install_db
a basedir
parameter like the following:
$ mysql_install_db --basedir="$(brew --prefix mysql)"