Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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 through socket

Discussion in 'Database Discussions' started by Cleyton Silva, Feb 21, 2017.

  1. Cleyton Silva

    Cleyton Silva Active Member

    Joined:
    Aug 9, 2016
    Messages:
    26
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Suzano, Brazil
    cPanel Access Level:
    Website Owner
    Hello, I have problems with my cpanel. When I log into MySQL® Databases
    An error message appears:

    The MySQL server is currently offline.
    Error while connecting to MySQL: (XID qpf9ac) Database Connect Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Error while connecting to MySQL: (XID qpf9ac) Database Connect Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/local/cpanel/Cpanel/Mysql.pm line 173.
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    15,745
    Likes Received:
    312
    Trophy Points:
    433
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Your forums Access level is Website Owner, do you have root access to the server you're on? If not, you might want to speak with your Hosting Provider about this.
     
  3. Cleyton Silva

    Cleyton Silva Active Member

    Joined:
    Aug 9, 2016
    Messages:
    26
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Suzano, Brazil
    cPanel Access Level:
    Website Owner
    Hello, thanks! I have access to root yes.
     
  4. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    599
    Likes Received:
    92
    Trophy Points:
    153
    Location:
    New Jersey
    cPanel Access Level:
    DataCenter Provider
    Can you confirm MySQL is online?

    In SSH simply type:

    Code:
    # mysql
    Does it bring up mysql prompt:

    Code:
    mysql>
    or throw an error?

    Also what does this give you:

    Code:
    # ll /var/lib/mysql/mysql.sock
     
  5. Cleyton Silva

    Cleyton Silva Active Member

    Joined:
    Aug 9, 2016
    Messages:
    26
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Suzano, Brazil
    cPanel Access Level:
    Website Owner
    I did the procedure and no error appeared.
     

    Attached Files:

  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Check to see if a .my.cnf file exists under the account's home directory (/home/$username/). If so, verify it uses the correct credentials, or try updating the individual account's MySQL password after consulting with the user via:

    "WHM Home » SQL Services » Change MySQL User Password"

    Thank you.
     
  7. vacancy

    vacancy Well-Known Member

    Joined:
    Sep 20, 2012
    Messages:
    140
    Likes Received:
    14
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    mysql log did you check?

    tail -f /var/lib/mysql/hostname.err
     
  8. germany

    germany Member

    Joined:
    Jul 15, 2016
    Messages:
    16
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    Berlin, DE
    cPanel Access Level:
    Website Owner
    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 file (/etc/mysql/my.cnf) and comment the bind-address field, and if you found any skip-network field comment it.
     
Loading...

Share This Page