酥hp 5.5隞乩 銝 mysql 5.2 嚗叮ysql隞 mysqli_connect() Y航炊mysqli_connect(): 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').
9 t! z8 f2 l9 S+ o* V$ l d$ \+ P1 B) t
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.* Z8 T/ ]0 U% n) o
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73). Q8 ^ t8 T1 \# Q! b1 y
餃叮ysql 嗅頛詨 :
* ?; M4 l0 h# x7 Pmysql> SHOW VARIABLES LIKE 'old_passwords';
9 e* R- u+ Q; @2 I: \5 C+------------------+-------+( y ^4 b/ l$ U# m/ R2 b
| Variable_name | Value |/ z6 d* w. F5 J
+------------------+-------+
* [" @ G" a8 P" n' l, [| old_passwords | ON |
! i' M+ ]& T& S/ \' U1 \8 U/ e2 q+------------------+-------+
7 m2 _- ]8 m3 W6 K1 row in set (0.00 sec)5 }; C; N P9 A& O6 C
( P" H% k3 y6 j; n% ~; N1 @
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
; v* J" w, C8 i* _/ A% s- C mysql prompt銝頛詨:8 J5 z3 y) D! O1 `
mysql> SET old_passwords=FALSE; 2 H1 z$ J; H. ~, H
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
}& ^1 ]% S2 z: @mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
5 D3 R- P/ U" _憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
) h5 f) { k9 _2 B/ @6 m0 L! e: z: u
( f7 T2 U. G! V" ^閮剖靘撖蝣:
0 f( ]& A5 B/ i, m/ l# umysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
$ ~9 d9 O& P9 h; G; I) R4 Gmysql> flush privileges;/ v5 E7 ^* H4 \' x6 u
: a6 C g6 o% e+ s' C7 A* M頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣7 e( b, N/ [. f) D! u( X# e
瘜冽:% _2 Q3 d: d3 S$ M
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================5 b. S4 O5 O' Q& W* O% V
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
" ]. O; K! `: f) fmysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers$ C. l6 }9 s& a: z
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
2 ~: D1 }6 x* L8 _:
1 W+ N" i5 [. ]' p4 y% f' r決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:5 ? ^" B. O' d4 i9 f# O
vi /etc/my.cnf 乩:
3 r7 ^0 g$ l9 [+ c& x: T) E* z[mysqld]
* K) a0 q, c6 M& x' E
" k) G! {' j- ^* r* A: j# O8 X; c7 Kcharacter-set-server=utf8* H! z% ~- _; d9 _1 G# ]
default_authentication_plugin=mysql_native_password
4 `* B' X" `/ i+ n+ q7 V* h, Y2 G0 S7 K, n2 r. o
[mysql]; k4 W- g# O- ^/ d# a
default-character-set=utf8
( X, ]7 v! b# i7 M, r I) w) c0 b% x1 N* L0 b0 ?; G& V2 y9 ^
[client]: u& e% X% M% A6 M
default-character-set=utf87 c B" n" {0 \9 o! B7 _1 `
1 d1 Q" C8 F' ^2 q0 O6 b嗅mysqld- d( M* B% F( T) |
service mysqld restart& ^9 z, [0 o6 M. e, r
摰!!' ~2 B" W5 a* X$ {. s7 A
( ~' F5 T6 N ]& F! S
& N! X! U+ e' ?7 b) W |
|