問題描述
我知道有很多類似的問題,事實(shí)上我已經(jīng)閱讀了所有 (9) 個(gè).
然而,它們都沒有解決我的問題.
我有一個(gè)共享主機(jī)包(最低限度).我的包中包含的是域名和托管 MySQL 服務(wù)器的單獨(dú) IP 地址.對(duì)于開發(fā),我將 http://localhost/
與 PHP 5.4 的開發(fā)服務(wù)器一起使用,并且我正在使用我在托管包中獲得的 MySQL 服務(wù)器.
這個(gè)問題只出現(xiàn)在我的電腦上,因?yàn)槲乙呀?jīng)安裝了 PHP 5.4,但是我的 web 主機(jī)已經(jīng)安裝了 PHP 5.2.17 并且不會(huì)升級(jí).MySQL 服務(wù)器在 MySQL 5.1.50 上.
幸運(yùn)的是,phpMyAdmin 具有內(nèi)置的更改密碼"功能.
phpMyAdmin 中有兩個(gè)用于更改密碼的散列選項(xiàng):
- MySQL 4.1+
- 兼容 MySQL 4.0
我使用 MySQL 4.1+ 選項(xiàng)更改了密碼,并確認(rèn)更新成功.
<塊引用>個(gè)人資料已更新.SET PASSWORD = PASSWORD('***')
但是,當(dāng)我執(zhí)行此查詢時(shí):
SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));
它告訴我密碼長(zhǎng)度仍然是 16.輸出:
<塊引用>1 1 16
所以問題仍然存在.
<塊引用>無(wú)法連接到數(shù)據(jù)庫(kù).SQLSTATE[HY000] [2000] mysqlnd 無(wú)法使用舊的不安全身份驗(yàn)證連接到 MySQL 4.1+.請(qǐng)使用管理工具通過命令 SET PASSWORD = PASSWORD('your_existing_password') 重置您的密碼.這將在 mysql.user 中存儲(chǔ)一個(gè)新的、更安全的哈希值.如果在 PHP 5.2 或更早版本執(zhí)行的其他腳本中使用了此用戶,您可能需要從 my.cnf 文件中刪除舊密碼標(biāo)志
當(dāng)使用 phpMyAdmin 中的 DBO 用戶登錄時(shí),我也嘗試執(zhí)行這些查詢:
SET SESSION old_passwords=0;[phpMyAdmin 重新加載到主屏幕,但值仍然 = 1]設(shè)置全局 old_passwords = 0;#1227 - 訪問被拒絕;您需要此操作的 SUPER 權(quán)限同花順特權(quán);#1227 - 訪問被拒絕;您需要此操作的 RELOAD 權(quán)限
這與用于設(shè)置 DBO 用戶的網(wǎng)站主機(jī)菜單中所述的內(nèi)容相矛盾:
<塊引用>數(shù)據(jù)庫(kù)所有者
創(chuàng)建新數(shù)據(jù)庫(kù)時(shí),需要指定一個(gè)Database Owner (DBO) User,該用戶具有
對(duì)數(shù)據(jù)庫(kù)的完全管理員訪問權(quán)限.
這是我必須與我的虛擬主機(jī)商解決的問題嗎?或者它可以由我的 DBO 用戶解決嗎?否則可以在PHP中繞過嗎?(因?yàn)樗m用于 PHP 5.2.17 但不適用于 PHP 5.4)
SOLVED!
盡管 SET SESSION old_passwords=0;
在 phpMyAdmin 中不起作用.
我下載了 MySQL GUI 工具并使用了 MySQL 查詢?yōu)g覽器在非 DBO 用戶上執(zhí)行相同的命令:
SET SESSION old_passwords = 0;
SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));
現(xiàn)在返回:
1 0 41
所以我只是更改了密碼:
SET PASSWORD = PASSWORD('my_old_password')
現(xiàn)在 PHP 5.4 PDO 連接到該用戶的數(shù)據(jù)庫(kù)!
I know there are a tonne of similar questions, in fact I've read all (9) of them.
However, none of them solve my problem.
I have a shared-hosting package (the minimum). What's included in my package is the domain name, and a separate IP address where the MySQL server is hosted. For development, I'm using http://localhost/
with PHP 5.4's development server, and I'm using the MySQL server I get in my hosting package.
The problem arises only on my PC, because I have installed PHP 5.4, but my web host has installed PHP 5.2.17 and won't upgrade. The MySQL server is on MySQL 5.1.50.
Luckily, phpMyAdmin has a built-in "Change Password" feature.
There are two hashing options in phpMyAdmin for changing a password:
- MySQL 4.1+
- MySQL 4.0 compatible
I changed the password with the MySQL 4.1+ option, and it confirmed the update was successful.
The profile has been updated.
SET PASSWORD = PASSWORD( '***' )
However, when I perform this query:
SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));
It tells me the password length is still 16. Output:
1 1 16
And so the problem persists.
Could not connect to database. SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file
I've also tried to do these queries, when logged in with the DBO user in phpMyAdmin:
SET SESSION old_passwords=0;
[phpMyAdmin reloads to the home screen, but the value remains = 1]
SET GLOBAL old_passwords = 0;
#1227 - Access denied; you need the SUPER privilege for this operation
FLUSH PRIVILEGES;
#1227 - Access denied; you need the RELOAD privilege for this operation
This is contradictory to what is stated in the webhost's menu for setting the DBO user:
Database Owner
When you create a new database, you need to specify a Database Owner (DBO) User, which will have
full administrator access to the database.
Is this something I have to take up with my webhosts? Or can it be solved by my DBO user? Otherwise can this be bypassed in PHP? (since it works with PHP 5.2.17 but not PHP 5.4)
SOLVED!
Although the SET SESSION old_passwords=0;
wasn't working in phpMyAdmin.
I downloaded the MySQL GUI Tools and used the MySQL Query Browser to execute the same command on non-DBO user:
SET SESSION old_passwords = 0;
SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));
now returned:
1 0 41
So I simply changed the password:
SET PASSWORD = PASSWORD('my_old_password')
And now PHP 5.4 PDO connects to the database with that user!
這篇關(guān)于PHP 5.4 PDO 無(wú)法使用舊的不安全身份驗(yàn)證連接到 MySQL 4.1+的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!