萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> 數據庫綜合 >> 解答關於MySQL5改密碼後不能登錄的問題

解答關於MySQL5改密碼後不能登錄的問題

這是關於解答關於MySQL5改密碼後不能登錄的問題的文章,仔細閱讀後使用一定會幫你解決問題的!

首先說明一下,下面描述僅限於Win系統 其它系統我沒試過,Mysql 自從4.1.1以後修改了用戶密碼的格式, 從16位增加到了41位, 采用了一種新的驗證方法,但4.1以前的客戶端協議不支持這種方法,所以造成了不能登臨的後果.即使密碼正確了不能正常登錄。

提示如下:

#1250 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

在窗口中執行:

C:mysqlin>mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 1 to server version: 5.0.0-alpha-nt

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> select password('aa');

+-------------------------------------------+

| password('aa')|

+-------------------------------------------+

| *DEE59C300700AF9B586F9F2A702231C0AC373A13 |

+-------------------------------------------+

1 row in set (0.00 sec)

mysql>

從上可以看出password的結果返回了一個以'*'號開頭的41位字符串,而以前是16位的.

Mysql官方網站給出了二種解決方法

1,使用新的客戶端api,

2,強制服務器使用舊的密碼方案

我首先嘗試了第一種方法,從mysql5.0中拷貝libmysql.dll到php 的擴展目錄中,替代了php本身附帶的libmysql.dll, 但結果令人失望. Php提示裝入php_mysql.dll失敗:PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php5/ext/php_mysql.dll' - 找不到指定的程序。後來發現新版的dll中缺少了mysql_drop_db() 這一函數 :( 只有等php或mysql出更新的dll了.

第一種方法行不通,只有試試第二種方法,mysql的官方FAQ中說,需要加上-old-password這一參數,我首先嘗試 在命令行下起動mysql,

c:mysqlin>mysqld-nt -old-password

在另一窗口中 運行

C:mysqlin>mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 540 to server version: 5.0.0-alpha-nt

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> select password('mypassword');

+------------------------+

| password('mypassword') |

+------------------------+

| 162eebfb6477e5d3  |

+------------------------+

1 row in set (0.55 sec)

mysql>

可以看出password的結果又變成16位的了,可喜的變化

我在c:windowsmy.ini (xp,98,中如此,2000中應在c:wint下)中的"mysqld"段中加入"set-variable=old-passwords"

例:

[mysqld]

basedir=C:/mysql

set-variable=old-passwords

datadir=C:/mysql/data

[WinMySQLadmin]

Server=C:/mysql/bin/mysqld-nt.exe

user=root

password=mypassword

然後在服務管理器中起動mysql

後來我又發現,只要在mysql.user表中把password的字段長度改成16系統就自動切換到了oldpassword方式,改成改回41後 又自動換到了新的驗證方式.在這裡提醒一下,更改password方式後,要重新設制一下密碼並刷新一下權限(或重起mysql)。

以上就是精品為大家整理的關於MySQL5改密碼後不能登錄的問題,希望對大家有所幫助。

copyright © 萬盛學電腦網 all rights reserved