www.computing-tips.net - Tips to help you in your computing life

Subscribe to our RSS FEED

Home | Software | Blog |

Article by: Charles M.
Last Modified: 2016-03-06 03:25:15

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

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
While trying to launch mysql, you get the error shown above, then you can get really frustrated. I got this error one time but for me I guess it was my ignorance. I had installed everthing except what I needed the most.

Solution to Mysql ERROR 2002 (HY000)

This is how I fixed the problem - "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)":

  • Mysql server was not installed
    Installed it with : yum install mysql-server.i686 -y - this is in Fedorah . If this is your issue, remember to initialize mysql by setting root password .
    yum install mysql-server
    You must start the mysqld service to continue
  • Invalid reference to your my.cnf file - see http://forums.mysql.com/read.php?11,27769,147093
  • If you get this error while working with php, you need to confirm if php.ini (/etc/php.ini) is set to the correct mysql socket file. Check the socket file settings for mysql in /etc/my.cnf and ensure it matches with php's . Edit accordingly and restart apache.
    edit mysql.socket settings in php.ini

Initialize mysql database

Setup new password for mysql as follows:

  1. Start mysqld service for it to create necessary tables and other information - service mysqld start
  2. On the console type /usr/bin/mysqladmin -u root password 'your-new-password'
  3. Restart mysql - just in case ;) - service mysqld restart
  4. Login into mysql from console and run a some grant queries
    Login to mysql and run grant queries

    GRANT some proviledges:

    mysql socket error

Try to connect to mysql server and things should work. At this point, its good to read more on mysql security : http://www.symantec.com/connect/articles/securing-mysql-step-step


Related Links:

Reader Comments

[2011-12-21] Katherine says:
TYVM you\'ve solved all my prbloems

Post your Comments

Your Name:
Email Address:
Bot Check: CAPTCHA Image
Enter the word on image above

No Comments
Home | Privacy | Contact | Disclaimer | Windows Xp
Copyright @ 2010