I install on my MacOS Sierra long time ago MySQL using brew install mysql and everytime I turn off and on my computer mysql started automagicaly what was great. But unfortunately yesterday I needed to temporarily shutdown MySQL - so I found on internet some command (but it was not brew services stop mysql) and after that when I reboot my computer MySQL not started (I was unable to connect by Sequel Pro GUI MySQL client). So I try to run it by:
brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
But I was still unable to connect :(
I try to connect by following command (to change root password) and get hint:
Mac-mini-Kamil:local Kamil$ mysqladmin -u root password 'xxxx'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
I type this 'hint' to internet and find out that I need run the following command:
mysqld
And that works :) (I was able to connect to my db)
Related
I tried a lot to install MySQL8 via Homebrew on Mac 10.14.5. I was running MySQL 5.7 before that and did the following: I removed MySQL completely via this tutorial: https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks
After that I run mysql and got the message that the command was not known. So I installed mysql with brew install mysql. After installation I did brew link --force mysql and got Warning: Already linked: /usr/local/Cellar/mysql/8.0.19
I edited /usr/local/etc/my.cnf and added default-authentication-plugin=mysql_native_password in the [mysqld] section. After that I restartet the service using brew services restart mysql
brew services list shows me this now:
mysql started root /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
mysql#5.7 stopped
However, when I type mysql in the terminal I get this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The /tmp/mysql.sock does not exist.
When I change the host in the my.cnf file from localhost to 127.0.0.1 this error will change into this:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 54
Anyone has an idea what's going on here and how I can fix it? I also googled it and found various Threads, some are saying that the permissions must be changed to this sudo chown -R _mysql:mysql /usr/local/var/mysql but this does not change anything in my case.
I upgrade OS X to High Sierra.
After upgrade, I found some services does not working correctly, which uses MySQL.
I try to connect by
mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
So I try to restart mysql service by
brew services start mysql
Could not find domain for
Error: Failure while executing; `/bin/launchctl enable gui/503/homebrew.mxcl.mysql` exited with 112.
mysql.server start
ERROR! The server quit without updating PID file (/usr/local/var/mysql/mangoui-Mac-mini.local.pid).
/usr/local/var/mysql/mangoui-Mac-mini.local.err
2018-07-27T05:32:37.570411Z 0 [ERROR] [MY-011071] [Server] /usr/local/opt/mysql/bin/mysqld: Error while setting value 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' to 'sql_mode'
Interesting point is
sudo brew services start mysql
command works.
So I tried
sudo mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
still get same error.
Please note that brew has recently upgraded mysql to 8.0, which causes some things to break due to deprecations (in my case 'sql_mode').
If you want to stay with 8.0, you can have a look at:
https://dev.mysql.com/doc/refman/8.0/en/upgrading.html
which will guide you through.
If you (for instance for compatibility reasons) decides to stay with e.g. 5.7 you can do e.g.:
> brew services stop mysql
> brew switch mysql 5.7.21
> brew services start mysql
> brew pin mysql # Tell brew to stay on this version
To see which version you have installed you can type:
> brew list --versions mysql
Good luck! Hope this helps :-)
I have a fresh OSX (Yosemite) installation i installed mysql using the following command
brew install mysql
Post installation it asked me to run the following command
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
After closing the iTerm and restarting when i try to access MySQL i get the following error
➜ ~ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I think you may just need to start/restart mysql now.
Try
mysql.server restart
I am a bit new Mac. I tried installing mysql5 using the following link:
http://matthewcarriere.com/2008/04/02/installing-mysql-on-mac-os-x-leopard-using-macports/
When I tried running the following:
sudo /opt/local/bin/mysqld_safe5 &
I got this:
[2] 59079
ps: No user named 'axww'
130911 13:35:11 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
After this, I tried the following:
mysqladmin5 -u root -p ping
I got the following error:
mysqladmin5: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!
How do I fix this?
That article is obviously a bit antiquated. The modern preferred way to start a daemon installed with MacPorts is by using the port load command.
sudo port load mysql5-server
Stop it by using port unload.
When I run the app, I will get this error message:
/Users/adam/.rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error)
If I try to run
mysqladmin variables | grep socket
The result is:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
I am pretty sure I was working with Rails 3.2 and MySQL, but now it doesn't. I am running on Mac OS Lion, could you help me please what am I missing?
Thank you
Type ps aux | grep mysqld in the terminal and see if anything shows up besides the grep command. If not, you're mysql server isn't running. Otherwise try typing mysqld start in the terminal and see if you can't get your sql server to boot up.
Edit: Sorry, on OSX the command to start it should be mysql.server start