hi
the only thing u need to do is just start ur mysql deamon

if on linux u can
/etc/rc.d/init.d/mysql start

or windows
c:/mysql/bin/mysqld.exe

this will work
if any problems let me know

cheers :-)
mandar@freeos.com

    Hi,

    There was no file mysql.sock at /var/lib/mysql/mysql.sock. mysql.sock lived at /tmp/mysql.sock where it does on our other (intranet) mysql installation. So, I copied it to /var/lib/mysql/mysql.sock but get the same error message as before. This is very frustrating. Does anyone have any further suggestions please? I've double-checked the mysql is running, by using 'mysqladmin version' this morning. It was still running fine. I just can't connect to it with PHP as yet. Doh!!!

    Graham

      if you can access mysqld using the mysql client application make sure that the user that php is running as has access to the socket file in /var/lib/mysql.

      so if php is compiled as an apache module it'll most likely be running running as user nobody/nobody. try:
      chmod +ox /var/lib/mysql
      to give user nobody access to the mysql folder (and the new mysql socket file).

      make sure that the databases are owned by the mysql user/group, and setup permissions on the databases folders so that only mysqld has rwx permissions to the database folders.

      check your permissions on the mysqld log as it can contain username/passwords.

      rather than copying the socket file you might want to create a /etc/my.cnf file and tell mysqld to create the socket file in /var/lib/mysql/. Or modify the mysqld startup/shutdown script and specify the socket file location using the --socket=/var/lib/mysql/mysql.sock option.

        Hi Folks:

        I have been "lurking" on this thread as I was at exactly the same problem point that you are/were at, Graham.

        Thanks, Brandon, as your point below solved two weeks of frustration (part time working in my server):

        "if php is compiled as an apache module it'll most likely be running running as user nobody/nobody.

        try: chmod +ox /var/lib/mysql to give user nobody access to the mysql folder (and the new mysql socket file). "

        After I ran this command it worked AWESOMELY

        Thanks, again, Brandon. It's people like you who volunteer their expertise that makes the 'net and open source systems great.

        Paul

          I have the same problem. I have read and done all the suggestions offered by Brandon, Paul, Mandar et al. Alas, I am still not up and running. Here is what I got.

          mysql.sock exists and looks like this :
          srwxrwxrwx 1 mysql mysql /var/lib/mysql/mysql.sock

          Running /etc/rc.d/init.d/myslqd start & returns [ OK ] every time without any other messages.

          Running /etc/rc.d/init.d/myslqd status returns
          mysqld dead but subsys locked

          Running /etc/rc.d/init.d/myslqd stop returns [ FAILED ] every time without any other messages.

          Running /usr/bin/safe_mysqld returns
          Starting mysqld daemon with database from /usr/lib/mysql
          010406 13:03:59 mysqld ended

          /usr/bin/mysqladmin status or /usr/bin/mysqladmin shutdown both return
          ERROR: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
          Check that mysqld is running and that the socket '/var/lib/myslq/mysql.sock' exists.

          Nothing gives me access to mysql through PHP. Also, there is no 'mysql' or 'mysqld' listed with a "ps -A"

          Any good pointers left out there? Thanks in advance... Gary

            Hi Gary:

            Here are some e-mails from someone who helped us:

            "it was all about permissions...
            
            from the command line can you get into mysql
            
            > mysql -p
            password
            
            mysql>
            ~~~~~~~~~~~~~~~~~~~~~~~~~
            Very Simple...
            
            there is a database in mysql called mysql
            
            select * from user;
            
            sets permissions...
            
            
            telnet into port 3306 on your local machine and tell me what the error is
            
            > telnet 127.0.0.1 3306
            
            This will help you see if it is accessible locally.
            
            ~~~~~~~~~~~~~~~~~~~~~~~~~
            you want to set your permissions within mysql.
            
            from the mysql prompt
            
            mysql>grant all on databasename.* to usename identified by "userpassword"
            
            this line allows that user to have full control over the database from
            anywhere
            
            mysql>grant select,update,delete,insert on databasename.tablename to
            username.localhost identified by "userpassword"
            
            more secure can't drop the database or its tables and only allows the user to connect from the localhost.
            
            The way you did it anyone can connect and have full control over your
            databases, even opening up security holes for any FTP user etc.
            
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            postings courtesy of Kurt Simons  (kurt@kurtsimons.com)
            
            I hope this helps, Gary.  
            
            Cheers,
            
            Paul

              mysql isn't starting.

              1) as root clear the lock file /var/lock/subsys/mysql

              2) restart mysql (/etc/rc.d/init.d/myslqd)

              3) look at the logs in /var/lib/mysql/*.err

              4) make sure the directory /var/lib/mysql/ is accessible also ("chmod o+rx /var/lib/mysql/").

                a month later

                Where do you type this in? At the regular shell prompt? In the mysql program? I'm new to this. Right now, the mysql.sock file lives in the /home/mysql directory on my server, but the .php file is looking for it in the /tmp directory. What would I need to do and where?

                Thanks in advance.

                  Hi Kelli:

                  I understand that this must be a pain. I hadn't used a command line prompt for admin stuff since back in the DOS days...it takes a while to get used to. No easy way around it. After a few months of Linux work, it becomes quite easy and powerful.

                  If you are trying to "type this stuff in", and you mean changing the permissions of the directory ("chmod"), then go to the directory right above the one which you want to change the directory of. Then change the permissions as Brandon notes by typing in the "chmod..." command. This allows PHP to work with (read, write, execute programs in) the contents of the directory - in this case the MySQL directory that it needs to access.

                  If you are unsure of how to work with command line prompts in Linux, grab any good Linux or Unix book and get a quick primer on moving around and doing stuff from the command line.

                  Good luck. Once you have the whole thing running, this problem will just be a "blip" in the past...

                  Paul

                    if php is looking for the socket in /tmp then change the php.ini file value for mysql.default_socket to "/home/mysql/mysql.sock".

                    if you have problems updating the file make a symbolic link from /home/mysql/mysql.sock to /tmp/mysql.sock.

                    at the command prompt:
                    ln -s /tmp/mysql.sock /home/mysql/mysql.sock

                      Great! Thanks, it worked.

                        a month later

                        I just ran across this discussion after spending 5 hrs trying to fix the same problem. Its done, I can sleep now.

                        Thanks a ton guys.

                        -Hrishi

                          17 days later

                          Found something that was interesting and might help you in future.

                          I had phpMyAdmin 2.1.0 giving me similar trouble...

                          The fix in the end combined creating a symlink to the correct location of mysql.sock

                          +

                          changing the script hostname to the actual IP...

                          I only worked it out by mistake when I used the IP in the browser instead of the servers name.

                          Hope that helps someone
                          🙂
                          Martin

                            11 days later

                            I am getting the exact error message has Gary Kiser. I have read all the responses in this thread and no one has solved the problem only Brandon Schnell came close to it.

                            I have been on this whole night, I was connecting but coudn't authenticate so I re-installed mysql, now it's not connecting at all. and I am stuck.

                              Somebody please help me out.. mysqld isn't running and I don't know what to do from here. I am new too to mysql and linux.. It's just giving me the same message.
                              "mysqld dead but subsys locked" why? why? why? aaaaaaaarggggggggggg!!!

                                Lot's of mails coming in my inbox from phpbuilder.com why is it?

                                  Well I fixed the proble. Took me the whole night last night. But today what I did was uninstall the mysql that i had 3.23.26 and installed the latest version from www.mysq.com version 3.23.39 I think it was.. much better version and it placed the mysqld in the /usr/sbin/ directory rather than the old /etc/rc.d/init.d/ path.. this is a really cool version you guys need to try this one out.

                                  Oh btw I installed the RPM for RedHat 7.1 and it's cool, no-prob-mon..

                                  Now i'm gonna try to see if it to start/stop on boot/shutdown.

                                  later guys..

                                    7 months later

                                    If anyone is still having problems try this.

                                    assuming mysql.mysql owns all the db files in /var/lib/mysql and all commands are type from / and are logged in as root or have su to root.

                                    if not: su root yourpassword

                                    (so that mysql can create the domain sock file mysql.sock and so that php as a module of apache can access mysqld's mysql.sock.)

                                    You see the thing is, if /var and /var/lib are set to 0700 then only root can read the mysql files, and if the user 'mysql' can't read the the /var or /var/lib directory's it can't find the /var/lib/mysql directory and therefore it can't create the domain socket /var/lib/mysql/mysql.sock

                                    So to make it so, you have to give 'other' (the fourth digit) read access, and ofcourse execute access to 'cd' the directory. Without execute access on the directorys, mysqld run as mysql, cannot go: cd /var/lib/mysql... so to speak.

                                    cd /
                                    chmod 0755 /var
                                    chmod 0755 /var/lib
                                    chmod 0755 /var/lib/mysql
                                    chown -R mysql.mysql /var/lib/mysql

                                    also this helps:
                                    ( so that mysql can create the file mysqld.pid)

                                    chmod 0755 /var/run/mysqld
                                    chown -R mysql.mysql /var/run/mysqld

                                    you can view the directory permission by doing this:
                                    ls -ald /var/lib/mysql
                                    -> drwxr-xr-x ## mysql mysql 4096 Feb 8 07:26 /var/lib/mysql

                                    and: ls -al -> to view the permissions of files in the directory.

                                    common access masks on files and directories.
                                    0700 : drwx------ <-- not good for this purpose
                                    only the user can view the contents of this directory, write or execute
                                    group and other are just screwed.

                                    0755 : drwxr-xr-x <-- what you want
                                    ( this is a directory, user can read, write, execute on to this directory, group and other can read and execute(cd ...), to this directory

                                    0660 : -rw-rw---- common data file setting
                                    ( user and group can read+write to this file, but other is screwed)

                                    I hope that helps! (otherwise I have had some good typing practice)

                                    Cheers,

                                    Jade

                                      a month later

                                      What follows is a sequence of commands and responses on my Linux desktop,
                                      describing the situation after I recovered from a general slowdown probably
                                      due to virtual memory problems (I had too many applications open for a long
                                      time, including Netscape, StarOffice, Acrobat, gvim).
                                      I read many entries in this section, but no response
                                      solves my problem, especially considering that all
                                      worked fine until now. I already rebooted, examined
                                      documentation, but cannot understand why it does

                                      not work.

                                      [root@localhost mysql]# uname -a
                                      Linux localhost.localdomain 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown

                                      [root@localhost mysql]# cat /etc/my.cnf
                                      [mysqld]
                                      datadir=/var/lib/mysql
                                      socket=/var/lib/mysql/mysql.sock
                                      [mysql.server]
                                      user=mysql
                                      basedir=/var/lib
                                      [safe_mysqld]
                                      err-log=/var/log/mysqld.log
                                      pid-file=/var/run/mysqld/mysqld.pid

                                      [root@localhost lib]# pwd
                                      /var/lib
                                      [root@localhost lib]# ls -l mysql
                                      drwxr-xr-x 10 mysql mysql 4096 Mar 19 22:00 mysql
                                      [root@localhost lib]# cd mysql
                                      [root@localhost mysql]# ls -l
                                      total 3532
                                      drwx------ 2 mysql mysql 4096 Jan 20 22:17 mysql
                                      srwxrwxrwx 1 mysql mysql 0 Mar 19 22:00 mysql.sock
                                      drwx------ 2 mysql mysql 4096 Feb 2 14:34 test
                                      drwx------ 2 mysql mysql 4096 Mar 17 17:59 timelog

                                      [root@localhost mysql]# /etc/init.d/mysqld stop
                                      Stopping MySQL: [FAILED]

                                      [root@localhost mysql]# /etc/init.d/mysqld start
                                      Starting MySQL: [ OK ]

                                      [root@localhost mysql]# ls -l /var/run/mysqld/mysqld.pid
                                      ls: /var/run/mysqld/mysqld.pid: No such file or directory

                                      [root@localhost mysql]# /etc/init.d/mysqld status
                                      mysqld dead but subsys locked

                                      [root@localhost mysql]# mysqladmin status
                                      mysqladmin: connect to server at 'localhost' failed
                                      error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
                                      Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

                                      [root@localhost mysql]# mysql -u mario -p
                                      Enter password:
                                      ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

                                      [root@localhost mysql]# cat /var/log/mysqld.log
                                      020319 21:54:40 mysqld started
                                      020319 21:54:41 bdb: PANIC: No such file or directory
                                      020319 21:54:41 Can't init databases
                                      020319 21:54:41 mysqld ended

                                      020319 21:59:08 mysqld started
                                      020319 21:59:08 bdb: PANIC: No such file or directory
                                      020319 21:59:08 Can't init databases
                                      020319 21:59:08 mysqld ended

                                      020319 22:00:51 mysqld started
                                      020319 22:00:51 bdb: PANIC: No such file or directory
                                      020319 22:00:51 Can't init databases
                                      020319 22:00:51 mysqld ended

                                      020319 23:25:30 mysqld started
                                      020319 23:25:31 bdb: PANIC: No such file or directory
                                      020319 23:25:31 Can't init databases
                                      020319 23:25:31 mysqld ended

                                      020319 23:52:48 mysqld started
                                      020319 23:52:48 bdb: PANIC: No such file or directory
                                      020319 23:52:48 Can't init databases
                                      020319 23:52:48 mysqld ended

                                      [root@localhost mysql]# /etc/init.d/mysqld status
                                      total 0
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 anacron
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 apmd
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 atd
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 autofs
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 crond
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 gpm
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 httpd
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 ipchains
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 keytable
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 kudzu
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 linuxconf
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 local
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 lpd
                                      -rw-r--r-- 1 root root 0 Mar 19 23:52 mysqld
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 netfs
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 network
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 nfslock
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 portmap
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 random
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 reconfig
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 sendmail
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 sshd
                                      -rw------- 1 root root 0 Mar 19 19:56 syslog
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 xfs
                                      -rw-r--r-- 1 root root 0 Mar 19 19:56 xinetd

                                        a month later

                                        Hi,

                                        I've read all the post and stil doesn't work with phpMyAdmin.
                                        Under command line, things are fine (login as root, non-root...) but got Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
                                        with phpMyAdmin

                                        The mysqld is on, mysql.sock is available at both places (tmp/mysql.sock & /var/lib/mysql/mysql.sock) with 0777 permissions.

                                        The only problem I might think of is about connecting from an intranet's machine. (eth0 is for apache and connect to the Internet, eth1 aliased eth1:1 for serving a virtual host at 192.168.1.200)
                                        From 192.168.0.3 (a machine in LAN) surf to 192.168.1.200, the web content was served correctly, but couldn't connect to mysql using both hostname={localhost|192.168.0.1}

                                        Any thought? I'm getting tired of trying modifying here and there! Thanks