I installed MySQL on Mac OS X Mountain Lion with homebrew install mysql
, but when I tried mysql -u root
I got the following error:
just hit "brew services start mysql" in terminal
If you are on OSX and have XAMPP,then please follow these steps:
Thanks to Jackstine's answer, I was able to do the following:
$ cat ~/.my.cnf
[mysql]
# CLIENT #
port = 3306
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
I hope this helps me again when I forget, in the future!
Looks like your mysql server is not started. I usually run the stop command and then start it again:
mysqld stop
mysql.server start
Same error, and this works for me.
Below I'm including the latest instructions from brew install mysql
so newer searches for this issue can benefit:
$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.6.26.yosemite.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring mysql-5.6.26.yosemite.bottle.1.tar.gz
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
In my case I loaded mysql now via launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
and was then able to launch $ mysql
and be on my way.
I hope this helps recent troubleshooters!
Encountered a similar problem after upgrading to Catalina OS. After running mysqld command, I found that there was some issue with the logs file. It could be different for others.
$ mysqld
Issue was
2019-10-16T04:58:59.174474Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: No such file or directory
2019-10-16T04:58:59.174508Z 0 [ERROR] Aborting
Resolved it by creating it and applying proper permissions.
sudo mkdir -p /var/log/mysql
sudo touch /var/log/mysql/error.log
sudo chown -R _mysql:mysql /var/log/mysql/
Restart MySQL
brew services restart mysql@5.7
Issue was resolved.
mysql -uroot -proot
It's probably because MySQL is installed but not yet running.
To verify that it's running, open up Activity Monitor and under "All Processes", search and verify you see the process "mysqld".
You can start it by installing "MySQL.prefPane".
Here is the complete tutorial which helped me: http://obscuredclarity.blogspot.in/2009/08/install-mysql-on-mac-os-x.html