Professional Web Applications Themes

Can't connect - MySQL

(also posted to alt.php.sql) This is an old problem. I extensively researched the postings on the internet and have found no solution. So, perhaps someone here can help. The problem is that from my index.php file I get: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' Now, when I do an ls -l '/var/lib/mysql/mysql.sock it shows that the daemon is running. It shows it there (size 0, as it should be). Furthermore, I can connect from command line and can do mysql commands. The mysql is on the same machine as the web server, so I use localhost as ...

  1. #1

    Default Can't connect

    (also posted to alt.php.sql)

    This is an old problem. I extensively researched the postings on the
    internet and have found no solution. So, perhaps someone here can help.

    The problem is that from my index.php file I get:

    Can't connect to local MySQL server through socket
    '/var/lib/mysql/mysql.sock'

    Now, when I do an ls -l '/var/lib/mysql/mysql.sock it shows that the daemon
    is running. It shows it there (size 0, as it should be). Furthermore, I
    can connect from command line and can do mysql commands. The mysql is on
    the same machine as the web server, so I use localhost as the host. php is
    running on the server as well. The ini file shows the default location of
    be empty, so it should default to the installation default of
    /var/lib/mysql/, and it does since it shows up with an ls.

    One post suggested changing ownership and group to mysql. I did that, but
    in reality that is how was originally anyhow.

    So, I am stumped. Are there any suggestions?

    Shelly



    Shelly Guest

  2. #2

    Default Re: Can't connect

    Shelly wrote:
    > (also posted to alt.php.sql)
    >
    > This is an old problem. I extensively researched the postings on the
    > internet and have found no solution. So, perhaps someone here can help.
    >
    > The problem is that from my index.php file I get:
    >
    > Can't connect to local MySQL server through socket
    > '/var/lib/mysql/mysql.sock'
    >
    > Now, when I do an ls -l '/var/lib/mysql/mysql.sock it shows that the
    > daemon
    > is running. It shows it there (size 0, as it should be). Furthermore, I
    > can connect from command line and can do mysql commands. The mysql is on
    > the same machine as the web server, so I use localhost as the host. php
    > is
    > running on the server as well. The ini file shows the default location of
    > be empty, so it should default to the installation default of
    > /var/lib/mysql/, and it does since it shows up with an ls.
    >
    > One post suggested changing ownership and group to mysql. I did that, but
    > in reality that is how was originally anyhow.
    >
    > So, I am stumped. Are there any suggestions?

    Login at the command line and enter 'status' and have a look at the 'UNIX
    socket:' line. I suspect it will be /tmp/mysql.sock, in which case you
    will have to tell php to use the correct socket or tell mysql to use the
    one in /var/lib/mysql


    --
    Brian Wakem
    Email: [url]http://homepage.ntlworld.com/b.wakem/myemail.png[/url]
    Brian Wakem Guest

  3. #3

    Default Re: Can't connect


    "Brian Wakem" <noemail.com> wrote in message
    news:436d43F1lc3tcU1individual.net...
    > Shelly wrote:
    >
    >> (also posted to alt.php.sql)
    >>
    >> This is an old problem. I extensively researched the postings on the
    >> internet and have found no solution. So, perhaps someone here can help.
    >>
    >> The problem is that from my index.php file I get:
    >>
    >> Can't connect to local MySQL server through socket
    >> '/var/lib/mysql/mysql.sock'
    >>
    >> Now, when I do an ls -l '/var/lib/mysql/mysql.sock it shows that the
    >> daemon
    >> is running. It shows it there (size 0, as it should be). Furthermore, I
    >> can connect from command line and can do mysql commands. The mysql is on
    >> the same machine as the web server, so I use localhost as the host. php
    >> is
    >> running on the server as well. The ini file shows the default location
    >> of
    >> be empty, so it should default to the installation default of
    >> /var/lib/mysql/, and it does since it shows up with an ls.
    >>
    >> One post suggested changing ownership and group to mysql. I did that,
    >> but
    >> in reality that is how was originally anyhow.
    >>
    >> So, I am stumped. Are there any suggestions?
    >
    >
    > Login at the command line and enter 'status' and have a look at the 'UNIX
    > socket:' line. I suspect it will be /tmp/mysql.sock, in which case you
    > will have to tell php to use the correct socket or tell mysql to use the
    > one in /var/lib/mysql
    It didn't understand "status".

    Shelly


    Shelly Guest

  4. #4

    Default Re: Can't connect

    Shelly wrote:
    > "Brian Wakem" <noemail.com> wrote in message
    > news:436d43F1lc3tcU1individual.net...
    >
    >>Shelly wrote:
    >>
    >>
    >>>(also posted to alt.php.sql)
    >>>
    >>>This is an old problem. I extensively researched the postings on the
    >>>internet and have found no solution. So, perhaps someone here can help.
    >>>
    >>>The problem is that from my index.php file I get:
    >>>
    >>>Can't connect to local MySQL server through socket
    >>>'/var/lib/mysql/mysql.sock'
    >>>
    >>>Now, when I do an ls -l '/var/lib/mysql/mysql.sock it shows that the
    >>>daemon
    >>>is running. It shows it there (size 0, as it should be). Furthermore, I
    >>>can connect from command line and can do mysql commands. The mysql is on
    >>>the same machine as the web server, so I use localhost as the host. php
    >>>is
    >>>running on the server as well. The ini file shows the default location
    >>>of
    >>>be empty, so it should default to the installation default of
    >>>/var/lib/mysql/, and it does since it shows up with an ls.
    >>>
    >>>One post suggested changing ownership and group to mysql. I did that,
    >>>but
    >>>in reality that is how was originally anyhow.
    >>>
    >>>So, I am stumped. Are there any suggestions?
    >>
    >>
    >>Login at the command line and enter 'status' and have a look at the 'UNIX
    >>socket:' line. I suspect it will be /tmp/mysql.sock, in which case you
    >>will have to tell php to use the correct socket or tell mysql to use the
    >>one in /var/lib/mysql
    >
    >
    > It didn't understand "status".
    >
    > Shelly
    >
    >
    You did this from a mysql command prompt, right?

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    [email]jstucklexattglobal.net[/email]
    ==================
    Jerry Stuckle Guest

  5. #5

    Default Re: Can't connect

    "Brian Wakem" <noemail.com> wrote in message
    news:436d43F1lc3tcU1individual.net...
    > Shelly wrote:
    >> The problem is that from my index.php file I get:
    >>
    >> Can't connect to local MySQL server through socket
    >> '/var/lib/mysql/mysql.sock'
    Make sure that socket file is readable/writeable by the uid that your
    Apache/PHP process runs under.

    Are you running SElinux (e.g. Redhat Enterprise Linux)? I have never been
    able to get MySQL to work while SElinux was enabled. Actually I'm surprised
    you got the daemon to run at all -- I have not been able to while SElinux
    was active.

    My solution was to turn off SElinux protection completely:
    # setenforce 0

    I think there are also settings to disable SElinux enforcement per daemon
    (see section 5.2.8 of
    [url]http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/selinux-guide/rhlcommon-section-0068.html[/url])

    Here's a thread from someone else who had the same 'socket' errors with
    MySQL and PHP, and disabling SElinux was their solution too:

    [url]http://forums.devshed.com/mysql-help-4/can-t-connect-to-local-mysql-server-through-socket-203593.html[/url]

    Regards,
    Bill K.


    Bill Karwin Guest

  6. #6

    Default Re: Can't connect

    Solution: The problem was in SELinux. It was too restrictive. The
    person doing our admin came to this conclusion and turned it off.
    Thank you, since if he hadn't found it, your answer would have done it
    for us.

    sheldonlg@gmail.com Guest

Similar Threads

  1. connect to SQL
    By boato in forum Coldfusion Database Access
    Replies: 5
    Last Post: March 13th, 01:32 PM
  2. How to use “RDS.Connect” to connect to a MS Access database?
    By hannaman@msn.com in forum ASP Database
    Replies: 0
    Last Post: August 2nd, 11:09 PM
  3. Connect to IDS 9.4 with 16 bit BDE
    By Yves Glodt in forum Informix
    Replies: 1
    Last Post: September 4th, 12:52 PM
  4. Cannot connect to db
    By dj Bass in forum ASP.NET Security
    Replies: 9
    Last Post: July 16th, 07:11 PM
  5. Can't Connect to PC on LAN
    By Robert L [MS-MVP] in forum Windows Networking
    Replies: 0
    Last Post: July 13th, 06:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139