MacOS High Sierra MySQL Error : error while setting value - mysql

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 :-)

Related

Can't connect to MySQL installed via Homebrew on Mac Monterey

I ma using M1 MacBook Air, and managing my tools with Homebrew.
I've installed Mysql, and it was working fine for a while, but when I've rebooted my device it just stopped working.
I don't get any errors when running brew services start mysql, but when I try brew services list MySQL is marked as stopped.
When I try to enter mysql with mysql -u user -p password I get following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When I run mysql.server start (as some answers suggest) I get following error:
. ERROR! The server quit without updating PID file (/opt/homebrew/var/mysql/MacBook-Air.local.pid).
I've tried many solutions, but non of them worked.
i fixed this error The server quit without updating PID on mysql version 8.0.18
try sudo chown -R mysql:mysql xx/mysql, and sudo chmod 775 xx/mysql
'xx/mysql' is your mysql home dir

Homebrew - brew mysql 8 - Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

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.

MySQL on MacOS installed by brew not working after shutdown

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)

Cannot get MySQL running in Terminal on macOS Sierra

I have been setting up a new laptop for development purposes and when trying to get MySQL to run in the Terminal I get the following message:
$ mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Can somebody please help me out here?
You may get this error because mysql server is not started. For me it solved only by starting mysql server.
to start Mysql server (for Mac OS X), command line in terminal:
sudo /usr/local/mysql/support-files/mysql.server start
or, simply go to your Mac System Preference --> MySQL --> click on start mysql..

mysql connection error on rails 2.3.14

I've been trying to work MySQL on Rails 2.3.14. I've to work with Rails2 but i can't work MySQL.
I've setup MySQL with brew according to http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/ this tutorial but when i tried to run
$ mysql
i've faced to
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Why?
Thank you.
All right mates.
I got it.
First I killed all mysql process
killall mysqld
and then I uninstalled mysql from brew
$brew uninstall mysql
$brew cleanup
after that I installed mysql again as http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/
so I fixed the problem.