Link to home
Start Free TrialLog in
Avatar of VincentLawlor
VincentLawlor

asked on

MySQL cannot connect to local MySQL server, why?

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)
Avatar of tdterry
tdterry
Flag of United States of America image

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
Avatar of VincentLawlor
VincentLawlor

ASKER

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

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/mysqld.pid
 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/mysqld.pid --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?
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
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.
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial