MySQL cannot connect to local MySQL server, why?

Posted on 2006-04-10
Last Modified: 2010-05-18
Hi All,

My first foray into the land of MySQL and Linux initially looked ok but after a reboot of my machine I am now getting the following.

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

It's mysql  Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i386)
Question by:VincentLawlor
    LVL 5

    Expert Comment

    Your server probably isn't running automatically on boot.  

    Check "ps ax | grep mysqld" to see if it's running.
    To start MySQL, run "/etc/init.d/mysqld start" or "/etc/init.d/mysql start"

    Adding MySQL to the boot script varies by Linux distribution.  For RedHat, use:
      chkconfig --add mysqld
      chkconfig mysqld on
    LVL 4

    Author Comment

    Hi I have tried what you have suggested and here is what I get:

    for ps ax | grep mysqld I get:
        8586    pts/2    R    0:00 grep mysqld
    for ps ax | grep mysql i get:
        8591    pts/2    R    0:00 grep mysql

    for "/etc/init.d/mysqld start" or "/etc/init.d/mysql start" I get:
        no such file or directory

    for  chkconfig --add mysqld
        chkconfig: command not found

    LVL 5

    Expert Comment

    Your ps should show something like:

     7824 ?        S      0:00 /bin/sh /usr/bin/safe_mysqld --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/
     7853 ?        Sl     8:25 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/ --skip-locking

    There should be something in /etc/init.d/ related to mysql, database, or something.  chkconfig lives at /sbin/chkconfig.  You have to be logged in as root, of course.  If you're using "su" to get root permissions, make sure you use "su -".  The '-' creates a login-type shell with the correct paths for the root user and utilities.

    I just noticed that your MySQL version says for "redhat-linux-gnu", so I assumed you were using RedHat.  What linux Distribution are you using?  What version?
    LVL 4

    Author Comment

    I am using RedHat Enterprise Release 2.4.21-4.EL

    Nothing in /etc/init.d/ related to mysql

    ps has the same result if I log in as root using "su -" but chkconfig runs
    LVL 4

    Author Comment

    Problem solved by uninstalling the MySQL packages and re-installing the rpms.
    Looked like the daemon was missing.

    Can I have this one closed and points refunded. Problem solved.

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
    Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (, A SQLite Tidbit: Quick Numbers Table Generation (…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 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

    14 Experts available now in Live!

    Get 1:1 Help Now