代碼如下 復制代碼old_passwords = 1//old_passwords = 1為16位//所以這裡要先//SET old_passwords = 0;//這樣使新密碼的長度也變成41位Restart MySQL. If you don’t, MySQL will keep using the old password format, which will mean that you cannot upgrade the passwords using the builtin PASSWORD() hashing function. You can test this by running:
代碼如下 復制代碼mysql> SELECT Length(PASSWORD('xyz'));結果如下圖:很明顯16位
The old password hashes are 16 characters, the new ones are 41 characters.2. Change the format of all the passwords in the database to the new format Connect to the database, and run the following query:
代碼如下 復制代碼如圖: Notice here that each user can have multiple rows (one for each different host specification). To update the password for each user, run the following:mysql> SELECT user, Length(`Password`) FROM `mysql`.`user`;This will show you which passwords are in the old format, ex:
代碼如下 復制代碼Finally, flush privileges:UPDATE mysql.user SET Password = PASSWORD('password') WHERE user = 'username';如圖:
代碼如下 復制代碼FLUSH PRIVILEGES;最後再查詢一下
代碼如下 復制代碼mysql> SELECT user, Length(`Password`) FROM `mysql`.`user`;結果如下圖:(變成41位了,成功)
成功後退出exit
最後重新啟動一下mysql
代碼如下 復制代碼service mysqld restartok
代碼如下 復制代碼 mysql>