HELLO-

I'm installind mysql on linux / apache server.
When i run try to start the server, it says it starts, then immediately ends.
It has to to with a socket reference. My error is:
"cant connect to local mysql server through socket '/var/lib/mysql/mysql.sock (111)'"

i get the same error with safe_mysqld

That would be because the mysql.sock file doesnt exist.
I tried re-installing, but that didnt help. I have been reading the manual too, but am unsure how to change the socket that it tries to connect through. I also dont know what socket to change it to, even if i knew HOW to change it.

Could someone PLEASE give me any hints!??
Thanks
mac

    Mac,

    I had the same problem, and it is aggravating to say the least...

    But this is what I did, and right now my mysqld (server) works every time I start it... :0)

    I went to mysql.com and got their newest stable version. I downloaded the file into
    /usr/local and I did tar -zxvf mysql.version#.tar.gz it will create mysql.version directory.

    My advice is to do this: rename this long directory name into just mysql. You can use shell commands or you can use mc (Midnight commander). (if you use mc open /usr/local on both panels, move cursor to mysql.version# directory and press F6. after the directory string /usr/local type mysql - hit enter - that will rename your directory....) mysql is whole lot easier to type then just mysql.version#....

    Then you go to /usr/local/mysql
    Type ./scripts/mysql_install_db 'This will install the database'
    Then make sure that your current directory is still /usr/local/mysql and type
    ./bin/safe_mysqld& to put it in the background....

    and then after your directory is still /usr/local/mysql
    type ./bin/mysql and you should be rolling....

    I've been using this setup for may be a week, and mysql works great with php and on its own...

    Hope that helps,

    Di

      5 months later

      Did exactly what you suggested (thanks) and got exactly the same error

      Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)

      Again I have no such file - I've tried making one, tried making a link to it etc etc

      Still no luck

      Any other ideas?

      Thanks

      Tom Smith

        Tom,

        Make sure you get a stable release of mysql. Another thing I can suggest is reboot.

        I know it sounds crazy to rebot *nix box, but one time that's what did the trick.

        I installed binary distribution of mysql, and when I tried to ./bin/safe_mysqld& it gave me an error that it cannot connect and etc... Well, I rebooted linux tried ./bin/safe_mysqld& again and what do you know - it worked...

        Other than that check mysql installation instructions from the documentation on www.mysql.com (Their manual is one of the best!)

        This is another link which deals with the problem you are facing.

        http://www.mysql.com/documentation/mysql/bychapter/manual_Problems.html#Can_not_connect_to_server

        Hope that helps,

        Dmitriy

        www.tftw.org

          Thanks Dmitriy

          Yes it did work but in a peculiar way.

          I've just installed 3.23.40 but it is 3.23.22 that is running (which was there from time ago)- (mysqladmin version)

          Never mind - at least I have something running now!

          Tom

            a month later

            I've tried all of the previous theorys, and still can't get it to work... I've tried rebooting before and after running mysql_install_db, but nothing helps. I've also asked a friend to copy the mysql.sock file for me, but he can't access it at all...

            has anyone got any idea on how to fix it?

              check mysql documentation. Their manual addresses this problem.

              Di

                No it doesn't it talks about how to protect the /tmp/mysql.sock file from being deleted if it exists. The problem I, along with others in this group r having is that we can't find the file on our system.

                I've tried connecting specifying a host and the client just hangs. Is there a way of recreating this file once it's lost? Can one of you that fixed this problem e-mail me the mysql.sock file (ben@dailystaple.com) thanx

                  a month later

                  hi,

                  I hope someone has found the soln to this problem.. If so Wud be really gratefull if you pl send me the mysql.sock file... been trying to start mysql for the past 3 days and everytime am getting a "unable to connect localhost error, missing mysql.sock"

                  I tried most of the suggestions found in the mysql documentation but nothing so far.. tried reinstalling too but nothing...

                  a strange thing, a couple of days back I did c the mysql.sock file in the /tmp dir but i can nolonger c it there.. did a find and came up with nothing.. AM i seeing things!!??

                  trying every method possible to get it started...wanna try and c if someone can send me the mysql.sock file and c if it works...

                  sands
                  sandeepmurthy@yahoo.com

                    o.k.

                    If it says unable to connect, than it means that your mysqld server isn't running.

                    After you get binary distribution of mysql you must create group and user mysql, than change ownership of /usr/local/mysql and /usr/local/mysql/data to mysql user
                    and chown /usr/local/mysql/bin to root

                    than try safe_mydqld&

                    Di

                      a month later

                      This error has teased me a lot too.
                      After having looked in var/log/mysqld.log I concluded that the sock message is wrong and it is caused by an incomplete install procedure:

                      011028 22:16:25 mysqld started
                      011028 22:16:25 /usr/libexec/mysqld: Table 'mysql.host' doesn't exist
                      011028 22:16:25 mysqld ended

                      The 'missing table' made me run the script mysql_install_db. I still got the silly sock error, but now mysqld stated:

                      011028 22:54:22 mysqld started
                      011028 22:54:22 /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
                      011028 22:54:22 mysqld ended

                      A search of the web quick told me that this error was caused by owner not being 'mysql'.
                      So I changed host.frm's directory and all its files with chown, and now I can start the mysql deamon.

                      Of course I immediately found that my PHP extention to Apache did not have mysql support installed and active, so I still have things to improve.

                      The lesson learned, I think, is that I have been too sloopy with selection of extra packages when installing RedHat 7.2.
                      I could not make the boot process 'full of OKs' so I reinstalled several times with LILO problems in mind and not mysql in mind.
                      So now that I have given up LILO in favor og the new multi boot loader from RH7.2, I will make yet another reinstall og my RH 7.2 workstation and really be carefull to mark all PHP and MySql packages.

                        4 months later

                        I have got the same problem of missing mysql.sock in my system......

                        Could you please someone email me a copy of this file . ....I would really appreciate that....

                          It's not a file that you can copy onto your system. It's some sort of socket that the system should create when you start the mySQL server. If it isn't being created you probably don't have your config file (my.cnf) set up properly. That was my problem.

                          -Ben

                            Thanks Ben:

                            I got the binary verion and it worked well. The problem for a rookie like me arose when I downloaded the binary file and treated as source file(compiling and configuring). If install.txt that comes with mysql(verion)installation is read carefully this problem should not happen to anyone.

                            matt

                              a month later

                              Ben -
                              I have had the same problem and have come to the same conclusion that my my.cnf file is not configured properly. Yet, as short as this file is, I haven't been able to get it configured right. Would you by chance be able to send me a copy of yours?
                              Thanks very much
                              /David

                                5 days later

                                Q1: Does anyone know why my "mysql.sock" file is empty? Is it normal or is something wrong with my mysql?

                                mysql in my linux box is running well but I get this error when I try

                                mysqladmin -u root -p password 'xxx'

                                ==================================

                                mysqladmin: connect to server at 'localhost' failed

                                error: 'Access denied for user: 'root@localhost' {Using password:YES}

                                Q2: The mysql.com doc says my my.cnf file may have wrong password. But I cannot tell when I viewed the file if the password is wrong or not. It is because the password and username have some characters preceding them. Should I just delete these characters from my.cnf file?

                                  7 days later

                                  the following fixes a missing sock file:

                                  (linux general commands independent of mysql)

                                  #make a sock file
                                  root] mksock /var/lib/mysql/mysql.sock

                                  #restart mysqld
                                  root] /etc/init.d/mysqld restart

                                  matt wrote:

                                  I have got the same problem of missing mysql.sock in my system......

                                  Could you please someone email me a copy of this file . ....I would really appreciate that....

                                    A sock file is a imaginary file (compare it to the floppy block device /dev/fd0)

                                    Its supposed to be empty.
                                    Its used as a socket of network information.
                                    It can be made with "mksock" make socket command.

                                      2 months later

                                      thanks for the advice here eddie. I am on RedHat7.2 and I have been messing about with this sock error for hours with no effect, but the '/etc/init.d/mysqld restart' command given above returned this:

                                      stopping mysql[failed]
                                      starting mysql[ok]

                                      Thus, it did the trick and now mysql loads ok. I'm still too new to mysql, so I don't really understand why it worked, but at least I can get on with it now!. cheers.