Page 1 of 1

php - MySQL Authentication

Posted: Sun May 21, 2006 7:18 pm
by rf
Hi,

When I run this script (with the correct password) :

<php>
$host="localhost";
$user="rf";
$password="correct";

if ($mysql_conn=mysql_connect($host, $user, '$password'))
{
$message = mysql_error();
echo "$message\n";
die("cannot connect to server\n");
print $mysql_conn;
}
<?>


I get this error message:

Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in /usr/local/apache2/htdocs/valade34a.php on line 6

2 questions:

Why does this script not work with all the right values?

What to do about it so I can connect to the MySQL server?

Thanks,


RF :D

Posted: Sun May 21, 2006 10:50 pm
by munky
make sure that your php is compiled with the mysql client library that is compatible with the version of mysql server you are running (ie - 3.23, 4.* , 5.*)

Posted: Mon May 22, 2006 12:25 am
by rf
I do not know how to tell :(

phpinfo() tells me:
php version 5.1.4
./configure --with-mysql --with etc.
[mysql]
client API version 3.23.56

mysql>status tells me:
bin/mysql ver 14.12 Distrib 5.0.20 for pc-linus-gnu (i686) using readline 5.0

2 Questions:

1. How to tell if your php is complied with mysql client library that is compatible with the version of mysql server?
2. How to fix it if it is not?

Thanks for your help :D

RF

Posted: Mon May 22, 2006 1:17 am
by munky
your php is compiled with 3.23, your mysql server is 5. you need to compile php with the mysql 5 client library

Posted: Mon May 22, 2006 7:20 am
by Nico
If your php binary came with your linux distribution and you can't (or don't want) to compile or upgrade (in case there's a newer binary available), you can try to following piece of advice from mysql:
http://dev.mysql.com/doc/refman/5.0/en/old-client.html

Posted: Tue May 23, 2006 12:54 am
by rf
:D Thanks much!

Not knowing how to make sure that my php is compiled with the mysql client library that is compatible with the version of mysql server you are running - I did the following:
cd /usr/src
rm -r php-4.4.2 and php-5.1.2 and everything I could find that looked older then php-5.1.4
then recompiled php

And this time phpinfo() showed the [mysql] client API version 5.0.20

and the error messages went away when trying to connect to MySQL

Thank you so much!

RF :D