Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) Problem

Posted on 2006-04-28
Last Modified: 2011-10-03
I'm really desperated with this problem, please someone help me, is very URGENT!!!

I have mysql installed over linux box. I  have phpmyadmin 2.6 installed on it.  I changed the pwd of root user, but I didn't know that account was related to a VERY IMPORTANT application. I tried to change the pwd in the application, but it told me: Access denied for user 'root'@'localhost' (using password: YES)  .

Then I tried changing the pwd back, shutting down the mysqld service and restarting it with --skip-grant-tables and after that I created a file with the following text:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypwd'). I named the file mysql-init and then run:
mysqld_safe --init-file=~/mysql-init &

It seemed to work fine, it displayed:
[root@declaranet bin]#  mysqld_safe --init-file=~/mysql-init &
[1] 30618
[root@declaranet bin]# Starting mysqld daemon with databases from /var/lib/mysqlSTOPPING server from pid file /var/run/mysqld/
060428 15:05:46  mysqld ended

but it doesn't return to the prompt, it keeps there after more than 30 minutes.

Then in another terminal I try  mysql -u root but it sends me the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

I really don't know what to do... It's VERY IMPORTANT and needs to be solved today.

Please, can someone help me???

Any help will be appreciated.
Question by:bethzycb
    LVL 8

    Assisted Solution

    LVL 2

    Accepted Solution

    The error message is really telling you that MySQL isn't running. Probably the way you are trying to start it isn't appropriate for your flavour of linux. The first place to check is the mysql log (probably in /var/log/mysql). If you're running Redhat try "service mysqld restart".

    You might also want to try killing all instances of mysql first, in case an old one is hanging around screwing things up (try "killall mysql" or "pgrep mysql" followed by kill -9 <mysql process number>).

    Alternatively, tell me what flavour of linux you're running and I can provide more detailed information.



    Author Comment

    Thanks patspam...

    You were right, the problem was with mysql not running, it seemed we had a problem with the daemon or something like that, furthermore, the password provided was wrong, that's one of the biggest problems, but we could make things work...

    Thanks both of u, the links Yuval_Shohat  provided gave us some light...

    LVL 2

    Expert Comment

    Glad you got it working :)



    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now