I have tried all the solutions to access mysql that are described before in stackoverflow.
When I type mysql and the terminal asks for password,when I type password and press enter it says ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Any idea,this problem making me crazy.
Thanks in advance.
Make sure you're starting the mysql server first. The command is sudo mysqld_safe. Also try looking at my.cnf (likely in /etc/) and search for "socket". You may need to change the socket location to /tmp/mysql.sock.
Related
Out of the sudden, I am getting this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
on mysql when I run mysql -uroot.
I haven't touched web dev for around 1 month and as soon as I wanted to return to my project, I am getting this very annoying error out of nowhere. I have trie all advice and solutions from other answers and none of them work. This includes changing permissions to 777, ownership to root, mysql etc, killing PID all of those and none of them work. I even tried re-installing mysql and still getting the same error. I even re-installed my whole macOS Mojave and still getting the same error. I mean this error doesn't even make sense...
Is mysql completely broken or I am just super dumb?
Has anyone had this issue? If so how did you solve it?
The error says, it's using the socket /tmp/mysql.sock and failed.
Try to troubleshoot with the below things.
check the process status of mysqld and confirm its running or not. If running which socket is using.
ps -ef | grep -i mysqld
Based on the socket file try login to the MySQL through command line.
mysql -uroot -p -S <<file.sock>>
Check the my.cnf to make sure which socket file its mentioned under the [client] group option.
In your case, probably the mysql instance reading the socket from my.cnf files where it placed somewhere. Check the hierarchy of the configuration file usage by mysqld which may be located in either the /etc or /etc/mysql
I have mysql database which was working fine earlier. After getting too many connections error. I have increased max connection and restarted my centos server. But after restart I used below command to connect to server.
mysql -uroot -p
But I am getting below errors.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2).
I tried all the options available on google. But it didn't worked for me. Some are saying to reinstall mysql, but I have data in GB's which I don't want to lost. Please can anyone help me to solve this problem.Thanks in advance.
Make sure you are indexing the right socket file.
Try this and provide the output.
check the socket in the my.cnf
cat /etc/my.cnf | grep -i socket
I downloaded Mac OSX MySQL Community edition (http://dev.mysql.com/downloads/mysql/), and when I start it at
/usr/local/mysql/bin/mysql
I meet with the following issue:
ERROR 2002 (HY000):
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Anyone have any good ideas? Thanks in advance.
Meeting with new issues cannot connect to local MySQL instance using MySQL WorkBench, here are my setup and error, looks access denied and anyone have any ideas?
Most likely the service isn't running or it's looking for the socket in the wrong path.
The /usr/local/mysql/bin/mysql call you made is actually the client, not the server/service.
There should be a mysql_safe executable in that same directory -- try calling that first (you may have to be root).
sudo /usr/local/mysql/bin/mysqld_safe
I have a problem installing mysql 5.5.20 on my ubuntu 11.10. after "ps -e | grep mysql" I found mysqld_safe and mysqld is running, but it is not right when I try to connect to the server, the error is like this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I have check the /etc/my.cnf which locate the mysql.sock in /var/lib/mysql/mysql.sock, and the access right of that folder is:
drwxrwxr-x 2 mysql mysql 4096 2012-01-17 01:54 mysql
after "find mysql.sock" I found it in /var/run/mysql, it is really confusing
any help will be appreciated, many thanks~
Often that error message can mean something wrong at an application level, rather than with MySQL.
Open Terminal and attempt to connect to MySQL.
mysql -u root -p
Press Enter, then enter your password and hit Enter again. Once you’re in, use SHOW DATABASES to find out what databases are available and if the one you’re trying to connect to is there.
I recently upgraded to a new macbook pro and haven't been able to get mysql to install. I have been trying to install using the:
mysql-5.5.8-osx10.6-x86_64.dmg
which 'should' work for my machine, but is not. After installing the three pieces (mysql.pkg,
startup.pkg, prefpane) I get nothing. Trying to start mySQL through the prefpane freezes sysprefs. Trying to start via the terminal gets this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
So I deleted all of the mysql install files and reinstalled following these instructions:
https://discussions.apple.com/message/12820394
when I get to the step where I would set up the root password i get the following error:
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!
This is perhaps due to the fact that there are no mysql related files in /tmp ? I can't find anything *.sock anywhere on my machine at all. I really don't know much about server admin, so I could be totally confused and off here.
It can have moved to /var/mysql/mysql.sock. I think it is the new position. You may need to point your php.ini to that or create a symbolic link to ln -s /var/mysql/mysql.sock /tmp/mysql.sock...