mysql and mysql workbench issue - mysql

So im trying to use mysql and mysql workbench on my macos 11. I cant connect to the sever or log in to root. I have no idea what the issue could be or how to fix it. I had it running perfectly about a week ago and now it feels like I will never have it running.
(base) Hank#Hanks-MacBook-Air ~ % mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Then i check if it is running and i get this error.
(base) Hank#Hanks-MacBook-Air ~ % mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/Hanks-MacBook-Air.local.pid).
Then i try again.
==> Successfully stopped mysql (label: homebrew.mxcl.mysql)
(base) Hank#Hanks-MacBook-Air ~ % brew services start mysql
==> Successfully started mysql (label: homebrew.mxcl.mysql)
(base) Hank#Hanks-MacBook-Air ~ % mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Related

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)

Since I've updated my Mac to the lastest OS version (Ventura 13.2) and I'he made some cleanup (hopefully I didn't remove any important file). I can't connect to mySql
I've insatlled mysql with brew (long before this update) and it always has worked fine.
When I run brew services start mysql in my terminal it looks to work (Successfully started mysql (label: homebrew.mxcl.mysql))
But, as soon as I run mysql -u root -p and I enter my password I have the following error message ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When I explore /tmp directory I see that /tmp/mysql.sock is a symlink to /var/lib/mysql/mysql.sock but mysql directory doesn't exist in /var/lib.
After extensive research I didn't find how to "get" this directory.
I've found many entries in StackOverflow with the same title, I've tried almost all answer but none seems to work. especialy in my case I'm using brew and macOS ventura.
Typicaly for ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' the accepted answer is not about brew.
I've tried brew reinstall mysql.
I've tried as well mysql -h 127.0.0.1 -u root -p in this case the error is ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (61).
I've tried to run mysqld and then brew services start mysql, in this case I have the following error
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/502 /Users/CedMacBook1/Library/LaunchAgents/homebrew.mxcl.mysql.plist` exited with 5.
I've tried to change my password using sudo mysqladmin -u root password -p and once again I have the error error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'.
It looks like mysql is runningm, I've ran ps aux | grep mysqld and get the following line:
CedMacBook 21853 0,0 0,0 34400496 2728 s000 S+ 7:53 0:00.01 grep mysqld
Finally I've checked my /usr/local/etc/my.cnf and I have the following
# Default Homebrew MySQL server config
[mysqld]
socket=/tmp/mysql.sock
# Only allow connections from localhost
bind-address = 127.0.0.1
port=3306
mysqlx-bind-address = 127.0.0.1
At this stage I'd be happy to swipe out everything... if I could save all my database
Please help, I don't know what else to try

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)

MySQL doesnt run on OSX after intall -- Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

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

Rails 3.2 - Can't connect to local MySQL

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