Hi.
I'm having a hard time to find out why is php giving me this error message:

Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) in /home/httpd/html/phpMyAdmin/lib.inc.php on line 255
Error

I found an article that
chmod 755 /var/lib/mysql
should correct the problem but it didn't.
I'm quite a newbie to LinuX (I have RH 6.2) and I can't seem to find a configuration file for mysql. Can somebody help me to find it? find / -name my.conf didn't find anything. Where should I set the configuration of host and port for mysql?
Thanx in advance.

... desperate ...

    a month later

    RPMs have a tendency of putting stuff in unorthodox places etc. I've given up using them at all.

    I would recommend installing MySQL from source. First, create a new user called mysql (or whatever), with a homedir but without login permissions (do not set a password). Then, install MySQL from source, the source package from http://www.mysql.com has instructions. In the first phase (./configure), define the MySQL user and also set the socket's location to the user's homedir. Do the rest of the installation as instructed.

    If you don't feel confident installing from source, try these:

    • check that mysqld is running: ps -ef | grep mysqld
    • check that /tmp/mysql.sock exists and also write note it's ownership and file permissions: ls -al /tmp/mysql.sock
    • check that you can log in locally: mysql -u username -p
    • can't? try: find /tmp -name ".sock", and: find /var -name ".sock"
    • if you found the socket file, try: mysql -u username -p -S /path/to/socket

    Also, from the help page of mysqld:
    "Default options are read from the following files in the given order:
    /etc/my.cnf /var/db/mysql/my.cnf ~/.my.cnf "
    You might want to check those files out.

    -jani

      2 months later

      I was experiencing exactly the same problem with RH 7.0

      chmod -R 755 /var/lib/mysql solved the socket connection problem. Now I have other problems :-)

        2 months later

        I encountered something similar after upgrading RedHat 7.0 and installing a new version of mysql. The problem is that the new install placed mysql elsewhere than the original install.

        The kludge fix was to create a LINK from where the old mysql.sock file was to where the new file was.

        1) find / -name mysql.sock -print
        To find the file

        2) ln -s <actual location> <the file php wants>
        For example, ln -s /var/mysql.sock /var/lib/mysql/mysql.sock

        --Me

          12 days later

          I've tried it before, it doesn't work... also...

          Yau Mo Gau Cho!!!!

            I've the same problem before...

            I found a correct answer from another site....
            http://www.phpwizard.net

            Try to set
            $cfgServers[1]['host'] = '127.0.0.1'

            in the config.ini.php3.

            Hahah... it works!!!

              That was exactly what was wrong on my system... Jeepers, i was getting pissed.

              Thanks!

              Andy

                a month later

                when i switched from using locahost to the real name of the server it worked... and all of it was installed from rpm in this case

                  2 months later

                  This may be of help to someone. After installing php on Mandrake, I needed to add this to /etc/php.ini:

                  mysql.default_socket = [path to mysql.sock ]

                    5 months later

                    OMFG YOU ARE A SAVIOR!! '127.0.0.1' works like a CHAMP! =)

                      Write a Reply...