First, I think <THINK> that by default the mysql.sock file is located at

/var/run/mysqld/mysqld.sock

By default make install's of mysql. First, check to see if this is right. If it is, for php to see your file socket, type in

ln -s /var/run/mysqld/mysqld.sock /var/lib/mysql/mysql.sock

This will create a symbolic link from the new one to where php intends to find it. Either that or recompile php, it should pick up the correct location.

Chris King

    • [deleted]

    First, what you think is nice but facts are better :-)

    find / -name "mysql.sock"

    will tell you where the file is when the mysqld is running

    BTW: use ps -wedaf to get a wider listing of processes

    Can you get into your mysql server using the mysql client program (without PHP)

      Try connecting to the database using it's IP address. If that works, go back and recompile PHP but this time point the with-mysql option to your MySQL libraries. That worked for me.

        Well, I decided to give the recompile a try. I still have the same error message.

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

        The only mysql.sock that I can find on my system is at /tmp/mysql.sock. I looked at my /etc/my.conf file (copied the my-medium.conf) and it appears to point to /tmp/mysql.sock.

        Do I need a /etc/php.ini file? I had one there that was from the old RPM, and I tried to rename that as php_old.ini, but no different.

        I haven't tried to put up symbolic links, but I don't remember doing that before. It sounds like a patch to something that isn't set right, but I can try it...

        veggie2u

          Damn people...lotsa guessing 🙂

          I had this same problem when I installed 4.0.5 from 4.04 today. You need to first, find your mysql.sock file then in the php.ini set
          mysql.default_socket=/tmp/mysql.sock
          but chaning the path to wherever your .sock exists.

            Tom, that sounds logical...

            I know where the mysql.sock is, but where do I get a php.ini file, and where should I put it. There is a php.ini @ /etc/php.ini that appears to have been put there by the old RPM. It has a lot of settings in there, that if it is being found, is pointing to the wrong place.

            I renamed that file to /etc/php_old.ini, and I still don't have it working. (meaning that I don't have one) - Do I need one?

            Is /etc/php.ini the place it should go? I noticed that there is a php.ini-dist. Should I use that?

            veggie2u

              Dude, don't use an rpm. Compile it yourself and use --with-config-file-path=/some/path/you/want
              then copy the php.ini-dist to /some/path/you/want/php.ini

              Tom

                Dude, I am referring to the RPM that RedHat would have used during the install. (Just installed RedHat 7.0)

                I have compiled new versions of mysql, php, and apache, and the mysql is biting me you know where with what appears to be left overs from the initial install.

                I have previously just used the binary distribution of my-sql (not RPM) that is from their site, but compiled it this time.

                I have previously compiled PHP, but never worried about a php.ini file. It appeared to work fine before. Where is the location that PHP would look for php.ini? When does it look for it? Do I just restart Apache to refresh it?

                veggie2u

                  create a page with just
                  <?
                  phpinfo();
                  ?>

                  and in the top table it will tell you where it is looking for the php.ini file.

                    I found via phpinfo() that it was looking in /usr/local/lib for the php.ini file. I copied the php.ini-dist there and called it php.ini. I edited the file to put in a value for mysql.default_socket = /tmp/mysql.sock

                    This worked, and Apache/PHP is now serving up data from my MySQL database.

                    Thank you,
                    veggie2u

                      I always like to use

                      locate -u
                      locate mysql.sock
                      locate php.ini

                      That gives me everything 🙂

                        • [deleted]

                        locate -u should be in the crontab to run daily.
                        If you just want to search for a file you just installed, a find will be faster because it reports as soon as it find the file, "locate -u" will first find all files and then look in the results for you file.

                        :-)

                          a month later

                          I have this exact same problem and its really frustrating. I can connect the MySql database from my Win 2K machine over the network, the phpinfo jobby spits all relevant data but cannot connect to the MySql database at all 🙁

                          really really frustrated!!

                          Adrian

                            got it

                            I was simply that apache did nto have read permisions to the mysql dir where mysql.sock was!

                            Soo simple really.

                            Now all I have to do it learn php!

                            Adrian

                              Write a Reply...