The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

'Can't connect to local MySQL server

Discussion in 'General Discussion' started by dSpotter, Apr 25, 2003.

  1. dSpotter

    dSpotter Registered

    Joined:
    Apr 25, 2003
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Houston, TX
    Hello,

    I just got my dedicated server and I keep getting this message in WHM:

    /usr/bin/mysqladmin: connect to server at 'localhost' failed
    error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
    Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

    I got a very similar message when I tried to add an account and that is the message I get in the "Show MySQL Processes".

    I'm a newbie at this so any help would be VERY appreciated!

    TIA!

    Derrick Lane
     
  2. HollyRidge

    HollyRidge Well-Known Member

    Joined:
    Feb 25, 2003
    Messages:
    138
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Garner NC USA
    cPanel Access Level:
    Root Administrator
    I have a server getting this same error. I have tried setting the mysql password as well as resetting the mysql and still no luck.

    Anyone have any ideas??
     
  3. sentry

    sentry Member

    Joined:
    May 7, 2003
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Connect to root via a shell and type:

    ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

    this should solve your problem ;)
     
  4. vishal

    vishal Well-Known Member

    Joined:
    Jan 28, 2003
    Messages:
    340
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    If not resolved ;)

    Got the same and resolved .

    This error generally occurs when mysql is not running.

    check ps auxwf | grep mysql ==> if nothing displays.
    check /tmp/mysql.sock ==> exists when mysql is running else no file is listed.

    /etc/rc.d/init.d/mysql start
    Or
    locate mysql.server
    /path/to/mysql.server start

    u'll not get the prompt after starting the service. It'll display mysql started from /var/lib/mysql....

    press enter.

    u r done :)

    Regards,
     
  5. HollyRidge

    HollyRidge Well-Known Member

    Joined:
    Feb 25, 2003
    Messages:
    138
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Garner NC USA
    cPanel Access Level:
    Root Administrator
    vishal you are actually pretty close to what resolved ours. I finally got it fixed and working but forgot to post back here. Anyway it would not even let me login to mysql through command prompt. Anyway I not exactly sure what fixed it but I had to end up forcing a password change to get into in. I kept playing around with it until it finally accepted it and went on working fine.
     
  6. nitromax

    nitromax Well-Known Member

    Joined:
    Feb 12, 2002
    Messages:
    189
    Likes Received:
    0
    Trophy Points:
    16
    I had been running MySQL 4 for over a month with no problems. Then I updated to WHM 7.1.0 cPanel 7.1.0-R20. Still no problems at this point. Then I updated /scripts/easyapache to the July 1st build. At that point MySQL gave me the following error:

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


    Then after trying some of the suggestions the error changed to this:

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


    I followed the directions in all of the related posts and nothing seemed to work for me. So here is what I did to finally make it work:

    I read a post at the RackShack forum that the following needed to be in the /etc/my.cnf file:

    [mysqld]
    set-variable = max_connections=500

    [client]
    port = 3306
    socket = /tmp/mysql.sock
    [mysqld]
    port = 3306
    socket = /tmp/mysql.sock


    I only had the first 2 lines, so I added the [client] and [mysqld] parts.


    Then I shut down mysql and chkservd with the following commands:

    service mysql stop
    /etc/rc.d/init.d/chkservd stop


    Then I removed the following files:

    rm -rf /tmp/mysql.sock
    rm -rf /var/lib/mysql/mysql.sock


    Now restart mysql and chkservd with the following commands and mysql will create the mysql.sock file in the /tmp directory as oulined in the updated my.cnf file:

    service mysql start
    /etc/rc.d/init.d/chkservd start


    Now create the softlink with this:

    ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock


    There were a couple of variations in that last last command to create the softlink. I guess it depends on where mysql creates the mysql.sock file when it starts. So if you are trouble shooting you might shut down mysql as shown above, then remove the mysql.sock files. Then restart mysql as shown above and see where it creates the mysql.sock file. If it creates it in the /tmp directory then you need the softlink command shown above. If it creates the mysql.sock file in the /var/lib/mysql directory then you problaby need to use the softlink command like this as shown in some of the other related posts:

    ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock


    That worked for me. Hope this helps someone down the line.

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page