Re: help with mysql connect error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stut wrote:
Tim McGeary wrote:
Tim McGeary wrote:
Stut wrote:
Tim McGeary wrote:
I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:

Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

Given that you can connect through the socket on the CLI, I'm gonna guess that it's a permissions issue. Does the user that Apache (or whatever web server you're using) runs as have access to mysql.sock?

Currently mysql.sock is owned by mysql.mysql with S777 permissions. Should the ownership be different? Despite the ownership, wouldn't S777 allow any user to access it?

Indeed it should. Have you tried writing a CLI script and seeing if that works?

I confess I don't know what at CLI script is.  What would I write?

To be run on the command line. Same as a web-based PHP script, but no need to output any HTML. Just write a script that tries to connect to the database and spits out success or failure. Then run php script.php on the command line (CLI === Command Line Interface) and see what happens.

-Stut

Oh, duh!  Ok.  I wrote this:

<?php
        $hostname = "localhost";
        $username = "softread";
        $password = "XXXXXXX";
        $dbname = "software";

        mysql_connect($hostname, $username, $password) or die(mysql_error());
        mysql_select_db($dbname) or die(mysql_error());

        $result = mysql_query("SELECT * FROM Requestor_type") or die(mysql_error());
        while($row = mysql_fetch_array( $result )) {
                echo '<input name="requestor_type" type="radio" value="'.$row['description'].'">'.$row['description']."&nbsp;";
        }
?>

And got this as output:

<br />
<b>Warning</b>:  mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in <b>/var/www/html/mysql_test.php</b> on line <b>7</b><br />
Client does not support authentication protocol requested by server; consider upgrading MySQL client

I'm not sure I understand it. Maybe my CLI PHP script is not correct? I'm returning to PHP after 5 years of not writing in it.

Tim

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux