mysql_connect(): Connection using old (pre-4.1.1) authentication protocol refused

做了一下mysql升級,開發機上mysql升級到5.6版本,結果連接一些低版本的mysql服務器報出如下異常:

Warning: mysql_connect(): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

異常原因在於服務器端的密碼管理協議陳舊,使用的是舊有的用戶密碼格式存儲;但是客戶端升級之後採用了新的密碼格式。mysql5.6版本遇到這種不一致的情況就會拒絕連接。

詳見mysql手冊“Server Command Options”一節中“--secure-auth"選項的說明:http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_secure-auth


解決方法有如下兩種:

1、服務器端升級啓用secure_auth選項;

2、客戶端連接時off掉secure_auth,即連接時加上--secure_auth=off,如:mysql -p10.51.1.11 -P3308 -uroot --secure_auth=off

對於方法二,使用在程序做相應mysql配置即可,以php爲例,在php.ini中設置secure_auth=off

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章