Page 1 of 1

Access denied for db_connect

Posted: Tue Dec 12, 2006 7:16 pm
by bwv2
Hello,

Until now I have been running my php code to connect to mysql using "admin" and my admin password.
Example:

Code: Select all

$conn = mysql_connect("localhost", "admin", "the_password") or die("Could not connect to MySQL: ".mysql_error());
So now I'm trying to transition the site to the public domain, and I don't want my admin username and pw out there in the code.

Here's part 2 of the story. I use my local machine to test all of the code before moving it to the server. Now, on my local machine I went into phpmyadmin and added a new user to mysql without admin access; just the necessary user permissions that a public user would need. I tested it on my machine and it worked. I changed all of my calls to:

Code: Select all

$conn = mysql_connect("localhost", "new_name", "new_password") or die("Could not connect to MySQL: ".mysql_error());
When I transitioned it to the server, however, it did not work. I got the following error:
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Inetpub\vhosts\the_website.com\httpdocs\yadayada\the_page.php on line 4
Could not connect to MySQL
Any inkling as to why this may not be working on the server? The permissions in phpmyadmin are exactly the same on the server as they are on my machine. I went into phpmyadmin for the server and set up the exact same thing.

Thanks.

Posted: Wed Dec 13, 2006 12:34 am
by dibyendrah
I think that is due to the old MySql client library. Maybe upgrading the mysql client and server will help you.

Posted: Wed Dec 13, 2006 12:38 am
by dibyendrah
If you don't want to upgrade to new MySQL client, do the following :

Edit the my.cnf or my.ini file and add following lines :

Code: Select all

#Use old password encryption method (needed for 4.0 and older clients).
old_passwords
Restart the MySQL server. Hope that will help you.

Posted: Wed Dec 13, 2006 2:02 am
by volka
topic has its own page in the mysql manual
http://dev.mysql.com/doc/refman/5.0/en/ ... uote]B.2.3. Client does not support authentication protocol[/quote]

Posted: Wed Dec 13, 2006 2:58 am
by dibyendrah