Hello everyone,

I have a little bit problem here.I have installed PHP version 4.4.1 and it's working well. I want to connect PHP with MySQl . I have also installed MySQL and it installed successfully.

Inorder to configure PHP to work with Mysql, I did the following changes in the c:\ windows\php.ini .

Uncomment (Removing semicolon) the line that follows extension=php_mysql.dll and extension=php_mbstring.dll .

The next step, i typed the following code in the notepad and saved it htdocs file and named as dbtest.php

<?php

$db_server = "localhost";
$db_user = "root";
$db_pwd = ""; //Enter your root password here.
$db_db = "mysql";

if (!$cnn = mysql_connect($db_server, $db_user, $db_pwd)) {
echo mysql_error();
exit();
}
if (!mysql_select_db($db_db, $cnn)) {
echo mysql_error();
exit();
}

$sql = "select * from help_category";
if (!$res = mysql_query($sql, $cnn)) {
echo mysql_error();
exit();
}
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
$data[] = $row;
}


?>
<html>
<head>
<title>Apache/PHP/MySql Test</title>
</head>
<body>
<h1>Help Categories</h1>

<?

echo "<style>table.dump { font-family:Arial; font-size:8pt; }</style>";
echo "<table class=\"dump\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\">\n";
echo "<tr>";
echo "<th>#</th>";
foreach($data[0] as $key=>$val) {
echo "<th><b>";
echo $key;
echo "</b></th>";
}
echo "</tr>\n";
$row_cnt = 0;
foreach($data as $row) {
$row_cnt++;
echo "<tr align='center'>";
echo "<td>".$row_cnt."</td>";
foreach($row as $val) {
echo "<td>";
echo $val;
echo "</td>";
}
echo"</tr>\n";
}
echo "</table>\n";

?>

</body>
</html>

then i run the dbtest.php in the browser.

I am getting an error msg as " Client does not support authentication protocol requested by server; consider upgrading MySQL client".

where do u think the problem lies?? I want to make sure that am i following the right direction.Am i missing something that still need to done??

I know this may sound basic but i really do not have any clue about this.Can someone help me ,please !!!

Any sugggestion or advice is appreicated.If anybody could help,please let me know.

Thanks in advance..

Cheers,
VG

Dani AI

Generated

Short answer: that MySQL error means the PHP/MySQL client library on your machine is speaking a different authentication protocol than the server expects — not a wrong database name or missing table. Newer MySQL servers (8.0+) default to the stronger SHA‑2 based plugin and older PHP/MySQL clients don’t understand it, so the server refuses authentication. (dev.mysql.com)

Best fix: move to a modern PHP build that includes up‑to‑date MySQL client support (mysqli or PDO compiled with mysqlnd). Upgrading PHP (or installing a current XAMPP/WAMP bundle as suggested) gets you compatible client libraries and avoids weakening security. was right to point at client compatibility — PHP4/old PHP5 builds are the real problem here. (php.net)

If upgrading isn’t possible immediately, a temporary workaround is to change the MySQL account to use the older mysql_native_password plugin (or, for very old servers, to generate a pre‑4.1 hash). This works but reduces security and is only a stopgap — don’t leave it in production. Example SQL (run as an administrative user):

ALTER USER 'youruser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPass';
FLUSH PRIVILEGES;

Or on very old servers:

SET PASSWORD FOR 'youruser'@'localhost' = OLD_PASSWORD('YourPass');

Use ALTER USER on modern servers; OLD_PASSWORD and old_passwords are deprecated. (dev.mysql.com)

Quick troubleshooting checklist: (1) view PHP’s configuration page (phpinfo) to see which MySQL extension and client API version are active; (2) check the server version with SELECT VERSION(); (3) inspect mysql.user’s plugin column to see which auth plugin the account uses; then either upgrade PHP/driver or ALTER the account as above. After changes, restart the server or FLUSH PRIVILEGES. (php.net)

If needed, include the exact php and MySQL versions here and someone can point to the least‑disruptive upgrade path.

Recommended Answers

All 5 Replies

Hey VG,

Upon first glance, I would suggest you try a lot less code for your initial run. A simple echo of "blah, blah" would suffice after you open the connection to the database.

I'm not real familiar with this specific error, but it sounds like it can't find the db. Here are some questions I have:

  • Is the database name really mysql? [If so, you might want to consider renaming it]
  • Is the db on this same machine or on the net? [If on another machine, your connection needs the address]

Also, I remember having to load the PHP and MySQL application files in the root of the machine. [i.e. - not in a subdirectory] So, maybe you want to check that out too.

Best of luck - you're doing good so far!

hummmm, may be incompetibility between versions

try to google and install "XAMPP" and run the same query on it........

if it is incompetibility between php and mysql these are latest versions preconfigured and you will solve the problem

G L

i am having problems getting mysql to work with php and apache. i have got apache running and php as well. all tested and working fine. i configured my php.ini file to recognize mysql but when i restarted the server and loaded the test page, i got a bland page instead. will be pleased if someone could help

Try making your own thread saidus9, don't hijack another person's.

Update to PHP5, unless you have very specific reasons for using PHP4.
The following link will explain the issue:

,
The error can't be related to his DB name or location because this is an authentication error. He has to be authenticated before it would attempt a connection with any database.

if the apache is working fine with the php create a php file and insert the following code in it;

<? echo phpinfo() ?>

if scroll through the generated page, if you should not see the mysql among then, try looking at your apache/config/httpd.conf.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.