php - MySQL Authentication

Post everything else here

Moderators: Website/Forum Admins, Other/Off Topic Moderators

rf
Posts: 30
Joined: Wed Apr 05, 2006 10:16 pm

php - MySQL Authentication

Postby rf » Sun May 21, 2006 7:18 pm

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
User avatar
munky
Site Admin
Posts: 826
Joined: Wed Jul 02, 2003 4:54 pm
Location: Phoenix AZ
Contact:

Postby munky » Sun May 21, 2006 10:50 pm

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.*)
In God we trust,
Everyone else must have an X.509 certificate.
rf
Posts: 30
Joined: Wed Apr 05, 2006 10:16 pm

Postby rf » Mon May 22, 2006 12:25 am

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
User avatar
munky
Site Admin
Posts: 826
Joined: Wed Jul 02, 2003 4:54 pm
Location: Phoenix AZ
Contact:

Postby munky » Mon May 22, 2006 1:17 am

your php is compiled with 3.23, your mysql server is 5. you need to compile php with the mysql 5 client library
In God we trust,

Everyone else must have an X.509 certificate.
Nico
Posts: 8
Joined: Sun Sep 05, 2004 11:12 am
Location: France

Postby Nico » Mon May 22, 2006 7:20 am

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
rf
Posts: 30
Joined: Wed Apr 05, 2006 10:16 pm

Postby rf » Tue May 23, 2006 12:54 am

: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

Return to “Off Topic”

Who is online

Users browsing this forum: No registered users and 2 guests