酥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')./ B8 W! p9 h8 K' r+ W- g- I6 N
5 O5 C% D+ d8 t- J, h* s4 l8 M臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.6 m8 c7 Z0 C4 s7 k4 l* g
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
& i/ Y& N, l1 q! B' l( Y0 O餃叮ysql 嗅頛詨 :
& ]' _ v9 J' f# Y& |9 K" a0 emysql> SHOW VARIABLES LIKE 'old_passwords';/ U5 o" a4 Q: Z! V% R
+------------------+-------+1 D8 S: K y8 ]+ o* @
| Variable_name | Value |
S5 F: F8 [. v* X+------------------+-------+7 G+ b8 H( h8 K8 l" H
| old_passwords | ON |1 P8 _: d+ B3 G8 U
+------------------+-------+
J3 p4 Z9 x" f, G) _3 K+ O1 row in set (0.00 sec)" a* o1 h9 z' f5 z1 {
3 q' F8 K. ]8 p$ B
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
! D2 s. L k3 h6 K. Y' j5 |4 f mysql prompt銝頛詨:
% f' y) R: {2 J" B5 E4 m9 h* Kmysql> SET old_passwords=FALSE;
0 U% O0 _7 V/ b8 {2 H' L6 O6 h瑼X叮ysql.user 瘥撖蝣潮瑕漲:0 i; c$ n+ l$ C8 Z' q( q z) x4 O, Z, n
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;0 ]/ x& C8 E; T5 h% H8 L8 Q+ o
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
: H/ c3 J( o5 _* O u5 u3 @* Y, @: l' q
閮剖靘撖蝣:
4 d& E' ~. U# jmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
' D# ~9 k/ J. s$ f& i1 x, s* j0 u; k1 Ymysql> flush privileges;6 l5 I0 I' J+ \) P, D! J
" A0 T" S: Z+ n. p& y頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣5 U) A& g5 s" i" a8 F& S) l& U
瘜冽:
# s7 ]' G2 ]9 R2 ^憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================2 `0 P1 }/ m5 ^5 {! P& `- U, L |1 t
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
+ i% m4 k8 t2 L: o7 D+ j4 ^ a' wmysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
2 {; c9 ?2 ^9 {: p3 P3 Nmysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers& q0 V' h. c/ `4 g+ H
:( M+ N7 c* ?& q3 j
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
# K! N5 Q8 I3 T$ ^vi /etc/my.cnf 乩:
2 s! O6 w! ~7 K[mysqld]" B3 a+ g+ V8 i; _$ z0 r
8 x" \3 |' t8 A: U8 `character-set-server=utf8( `6 _5 ~" R! o8 `
default_authentication_plugin=mysql_native_password$ q" ?1 u* Q9 s; ]& |7 `! D
X3 E; k& z o1 g5 s) K) I$ A0 k
[mysql]
2 l5 y( P! ]! Z5 V& l( {) g; Gdefault-character-set=utf8
. @8 S, Q- ]0 O( }1 y9 o' W* ~3 `8 c( e2 |, @
[client]
$ S( T1 y: T' J9 K1 Z% t9 C" [ s: vdefault-character-set=utf8
' ?7 U& [3 v- b9 n4 G8 \9 t! b( S" C5 c l- Y c8 |1 z
嗅mysqld1 {$ D/ w i. v. R7 H5 n
service mysqld restart. T5 c' C3 c. m# {, ? ]
摰!!
2 y6 J3 k9 {+ w0 ^ W
. h, o0 r0 ]4 n" E% o$ A3 I0 ~
7 E5 }) W5 t. W D% U8 M |
|