Mysql Error 2002 Mysql.sock
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38) up vote 228 down vote favorite 68 I am having a big problem trying to connect to mysql. When I run: /usr/local/mysql/bin/mysql start I have the following error : Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38) I do have mysql.sock under the /var/mysql directory. In /etc/my.cnf I have: [client] port=3306 socket=/var/mysql/mysql.sock [mysqld] port=3306 socket=/var/mysql/mysql.sock key_buffer_size=16M max_allowed_packet=8M and in /etc/php.ini I have : ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = /var/mysql/mysql.sock I have restarted apache using sudo /opt/local/apache2/bin/apachectl restart But I still have the error. Otherwise, I don't know if that's relevant but when I do mysql_config --sockets I get --socket [/tmp/mysql.sock] mysql share|improve this question edited Jun 27 '12 at 15:18 Carrie Kendall 7,81543766 asked Mar 21 '11 at 10:33 Lambivist 1,1892810 31 Is MySQL running? –David Mar 21 '11 at 10:39 I'd supplement @David, you should look at the MySQL log to see if the server is actually running or if it has crashed/is not ready to accept connections. –Romain Mar 21 '11 at 11:02 No, mysql is not running, i have the "Can't connect....."error –Lambivist Mar 21 '11 at 11:13 1 I was getting the same error, but in my case, I found out mysql wouldn't start because the disk was 100% full. /var/log/mysqld.log was helpful. –yellavon Nov 8 '12 at 22:15 1 the reason they are asking if it is running, i presume, is because the socket is made when the service starts. i installed mysql, but never started the service, so the .sock file doesn't exist. type service mysqld start if you just installed. hth –changokun Mar 7 '13 at 13:48 |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2) up vote 17 down vote favorite http://stackoverflow.com/questions/5376427/cant-connect-to-local-mysql-server-through-socket-var-mysql-mysql-sock-38 7 I'm getting this error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2) even though I have managed to start mysql via command line in ubuntu mysql stop/waiting mysql start/running, process 17691 However when attempting to access the site I get a database connection error as well as the above error when trying to access mysql via mysql -u root -p I checked my error logs and http://stackoverflow.com/questions/19658891/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run I saw this 131029 12:53:34 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be remo$ 131029 12:53:34 [Note] Plugin 'FEDERATED' is disabled. 131029 12:53:34 InnoDB: The InnoDB memory heap is disabled 131029 12:53:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins 131029 12:53:34 InnoDB: Compressed tables use zlib 1.2.3.4 131029 12:53:34 InnoDB: Initializing buffer pool, size = 26.0G 131029 12:53:36 InnoDB: Completed initialization of buffer pool 131029 12:53:36 InnoDB: highest supported file format is Barracuda. 131029 12:53:38 InnoDB: Waiting for the background threads to start 131029 12:53:39 InnoDB: 5.5.34 started; log sequence number 5146431500 131029 12:53:39 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 131029 12:53:39 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 131029 12:53:39 [Note] Server socket created on IP: '0.0.0.0'. 131029 12:53:39 [Note] Event Scheduler: Loaded 0 events 131029 12:53:39 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.5.34-0ubuntu0.12.04.1-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu) It's the first time I see this error and I'm not sure how to solve this issue, please help me out a bit here. Thanks UPDATE Okay I tried glglgl's solution and after a restart, I get the following in the error log: 131029 13:17:36 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be remo$ 131029 13:17:36 [Note] Plugin 'FEDERATED' is disabled. 131029 13:17:
have one accepted answer. Are you sure you want to replace the current answer with this one? Yes, https://www.digitalocean.com/community/questions/mysql-can-t-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2 I'm sure. Changed your mind? You previously marked this answer as accepted. Are you sure you want to unaccept it? Yes, I'm sure. Sign Up Log In http://forums.mysql.com/read.php?11,27769,59865 submit Tutorials Questions Projects Meetups Main Site logo-horizontal DigitalOcean Community Menu Tutorials Questions Projects Meetups Main Site Sign Up Log In submit View All Results By: decaobr Subscribe mysql error Subscribed Share 1 MySQL -Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) September 30, 2014 85.8k views I currenty have a LAMP, running on Ubuntu 14.04, yesterday everything was fine, but today my MYSQL is not working. When i try to connect via mysql -u root -p I get the error: ERROR 2002 mysql error 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) the Mysql.err file is completely empty, and have absolute no ideia about what to do. 2 comments 0 empty September 30, 2014 Is it running? 3 sreejithkb September 18, 2015 I think you didn't started your database server, start it using #services mysql start or #/etc/init.d/mysql start If you are getting a failure message while starting, check the log file (/var/log/syslog), if you found socket connection error message there, then check for correct socket file location #find / -type s, if you found a mysqld.sock file under /var/run/mysqld/ directory, check whether any instances of mysqld running or not #netstat -anpt | grep 3306 or #ps aux | grep mysqld if you found any running process stop it (#kill -9 pid) and remove the socket file. Then try to restart it and if mysql not creating socket file then try start it like #/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock Also check your my.cnf
Community Podcasts MySQL.com Downloads Documentation Section Menu: MySQL Forums :: Install & Repo :: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) New Topic Advanced Search Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Posted by: Jakub TCP () Date: December 15, 2005 09:07AM Here we go............ There are two things that could go wrong here: 1. You don't have permissions to access the directory /var/lib/mysql/whatever.sock because mysql is the owner of the folder or 2. /path/whatever.sock doesn't exist. You can try this though [Linux specific, but what other operating systems are there?] Go to /etc/my.cnf and change/add the lines: [mysqld] datadir=/var/lib/mysql socket=/tmp/mysql.sock [client] socket=/tmp/mysql.sock This way the client and server use the same socket and it's in a public directory. This solves my MySql problems 98% of the time. Jakub TCP Linux localhost.localdomain 2.6.9-11.ELsmp Navigate:Previous Message•Next Message Options:Reply•Quote Subject Written By Posted ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Vacheh Sardarian 05/29/2005 01:34AM Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Ricardo Garcia Chavarry 10/08/2005 03:51PM Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) erick adienge 11/10/2005 12:07PM Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Paul KOENIG 11/19/2005 03:33AM Unable to start mysqld Abhijit Mapgaonkar 03/03/2007 04:06AM Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Cristea Cristina 06/11/2008 03:32AM Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) John G 09/01/2008 06:23AM Mac OS 10.5 Semi-Solution Jon Ohliger 01/08/2009 02:01PM Re: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2