Access denied for db_connect

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bwv2
Forum Commoner
Posts: 83
Joined: Fri Jun 10, 2005 11:50 am
Location: AZ

Access denied for db_connect

Post 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.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

I think that is due to the old MySql client library. Maybe upgrading the mysql client and server will help you.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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]
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Post Reply