09/10/2018, 23:19

không kết nối được với mysql, giúp mình với

Mình viết đoạn mã php để kết nối với mysql:
<?php
$link=mysql_connect ("localhost","root","root")
or die ("Could not connect");
print("Connected successfully");
mysql_close($link);
?>
Khi chạy thì hiện lên thông báo lỗi:
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in c:inetpubwwwrootinfo.php on line 2
Could not connect
Ai biết lỗi này là gì và sửa ntn không giúp mình với, mình cám ơn nhiều nhiều.
(ah, mình config mysql với user: root và pass: root)
cactus_vn viết 01:21 ngày 10/10/2018
Bạn chạy file này trên máy tính của bạn hay trên host? Nếu chạy trên host bạn cần hỏi lại nhà cung cấp, nhiều máy chủ chỗ "localhost" phải thay bằng tên khác đấy!
amida viết 01:24 ngày 10/10/2018
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in c:\inetpub\wwwroot\info.php on line 2
Bác cactus_vn này lạ, nhìn kô rõ gì hết.
phong-wint viết 01:22 ngày 10/10/2018
Chỉ ra cho sai đi, chu bao lên trên php.net xem nửa.Tôi cũng gặp lỗi như vậy đấy, giúp luôn đi
jiSh@n viết 01:30 ngày 10/10/2018
Xem trên php.net nè:
Quote Được gửi bởi Anthony Boyd (26-Jul-2005 11:53)
Some versions of PHP do not support the new longer passwords used by MySQL 4.1 and later. This will cause the error message that 2raptor mentioned a few posts prior to this one:
"Client does not support authentication protocol requested by server; consider upgrading MySQL client"
However, for ease of use, let's review the two fixes right here.
First, you should upgrade to a newer PHP that supports the longer MySQL passwords. However, I don't even know if the PHP 4.x series has been upgraded to handle this yet. So for my installation, I took a different approach -- I downgraded MySQL's passwords to the "old" shorter encryption. Here's how:
SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
As a real-world example, I used this query:
SET PASSWORD FOR 'testaccount'@'%' = OLD_PASSWORD('secret');
Suddenly, PHP could use the testaccount to access the database. Yay.
-Tony
Quote Được gửi bởi omikorn at yahoo dot com (04-Dec-2004 11:21)
maybe you have seen this (using PHP 4.3.9 and MySQL client/server 4.1)
Error w/ php: mysql_connect(): Client does not support authentication protocol
Solution:
mysql -u root-p
SET PASSWORD FOR user@localhost = OLD_PASSWORD('password');
It is clearly that this is a bug in PHP's mysql module, perhaps it will be upgraded in the next version
Resource: http://forums.mysql.com/read.php?11,6400,6701#msg-6701
Bài liên quan
0