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
Related
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
After resizing the server at DigitalOcean, MySQL no longer works. I restarted MySQL. Upgraded MySQL. Restarted WHM. Nothing works. I think it has to do with mysql.sock. But I tried every solution on stackoverflow. Still doesn't work. Would you mind taking a look?
[root#ns ~]# mysqladmin -u root -p status
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
Screenshot Terminal error
Screenshot phpMySQL error
In order to trace the issue, we would need some more information, please post the output from your MySQL log .
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)
I installed LaMp 2 days ago. First everything works;
But until yesterday, I can't start anymore mysql server : it failed each time.
When I look at the status :
systemctl status mysql
Failed to get D-Bus connection: Erreur inconnue -1
It's like it can't generate mysqld.sock
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I keep reading man and trying to find something I didn't configure correctly, but I can't find nothing.
Please, help me to resolve that problem.
Try to use this command in a terminal:
sudo service dbus restart
or this:
sudo /etc/init.d/dbus restart
Probably this is a temporary solution, this means that you'll have to do that command everytime you got the dbus error.
I run the mysql command at the command line but I get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I've Googled a lot but I'm unable to resolve the issue.
Please HELP!
It sounds like mysql isn't running. This will tell you if it is or not:
sudo netstat -tap | grep mysql
That's because the path you specified doesnt have the socket required to connnect to the mysql. This problem has happened with me. Either you can reinstall mysql or search for the mysqld.sock and then move it to the specified directory.
Try running this command to start the mysql server
/etc/init.d/mysql start
/etc/init.d/mysql restart