PHP Warning Mysql Connect

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Warning: mysql_connect(): Client does not support authentication protocol

requested by server; consider upgrading MySQL client in ….

สําหรับ PHP ที่เรียกใชงาน mysql_connect เพื่อทําการเชื่อมตอกับ MySQL database แลวปรากฎ


ขอความ warning ดังตอไปนี้
Warning: mysql_connect(): Client does not support authentication
protocol requested by server; consider upgrading MySQL client in ….
เนื่องจาก ใน MySQL 4.x ขึ้นไปนั้นไดมีการเปลี่ยนการเขารหัสของรหัสผานจาก 16 bit เปน 48 bit ดังนั้น
client ที่เกากวาบางตัวจะไมสามารถเขาใชงานได
วิธีแกมี 3 วิธีคือ
1. แก MySQL server ใหใชการเขารหัสแบบเกา
2. แกรหัสผูใชใหเปนแบบเกา
3. เปลี่ยน client
แก MySQL server ใหใชการเขารหัสแบบเกา
start server โดยกําหนด --old-passwords option หรือไปแกในไฟล my.cnf
$mysqld --old-passwords

แกรหัสผูใชใหเปนแบบเกา

mysql> SET PASSWORD FOR


-> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
mysql> FLUSH PRIVILEGES;

หรือ

mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')


-> WHERE Host = 'some_host' AND User = 'some_user';
mysql> FLUSH PRIVILEGES;

เปลี่ยน client
เปลี่ยน Client ใหม เปลี่ยนมาใช mysqli แทน (เปน Library ของ PHP5.x แตมีของเวอรชั่น 4.x ดวย)

You might also like