做了一下mysql升級(jí),開(kāi)發(fā)機(jī)上mysql升級(jí)到5.6版本,結(jié)果連接一些低版本的mysql服務(wù)器報(bào)出如下異常:
Warning: mysql_connect(): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)
異常原因在于服務(wù)器端的密碼管理協(xié)議陳舊,使用的是舊有的用戶(hù)密碼格式存儲(chǔ);但是客戶(hù)端升級(jí)之后采用了新的密碼格式。mysql5.6版本遇到這種不一致的情況就會(huì)拒絕連接。
詳見(jiàn)mysql手冊(cè)“Server Command Options”一節(jié)中“--secure-auth"選項(xiàng)的說(shuō)明:#option_mysqld_secure-auth
解決方法有如下三種:
1、服務(wù)器端升級(jí)啟用secure_auth選項(xiàng);
2、客戶(hù)端連接時(shí)off掉secure_auth,即連接時(shí)加上--secure_auth=off,如:mysql -p10.51.1.11 -P3308 -uroot --secure_auth=off
3、找到對(duì)應(yīng)的mysql用戶(hù)把密碼改為新的加密方式,PASSWORD(‘your password'),如:
復(fù)制代碼 代碼如下:
SET PASSWORD FOR root=PASSWORD('123456');
對(duì)于方法二,使用在程序做相應(yīng)mysql配置即可,以php為例,在php.ini中設(shè)置secure_auth=off
新聞熱點(diǎn)
疑難解答
圖片精選