酥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 u* o9 ?+ n6 f# g
3 ?& C1 ?- C9 p% o2 W臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
2 A1 l9 e( c2 G5 K0 q# B0 F$ x閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)6 f# ^% j5 c) o( p# Y) B
餃叮ysql 嗅頛詨 :
( r! `6 h( k1 [* \0 a' ]2 Z( `- omysql> SHOW VARIABLES LIKE 'old_passwords';# a/ [7 z* ~) B3 x F
+------------------+-------+( |1 F1 j; [7 C' Z6 ~
| Variable_name | Value |$ j" K3 E( L7 ~: P1 `7 \% z& k" K
+------------------+-------+
) \) T g, |1 }$ y" g| old_passwords | ON |
3 V J1 l' b0 x' S. g: A+------------------+-------+: P5 h8 V/ m# X
1 row in set (0.00 sec)* ^9 V. p/ @5 G
) A" t; [6 P. E1 q+ F
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
' F1 D/ d9 g8 b3 y& X mysql prompt銝頛詨:
; [. i2 i& `0 s+ l: {mysql> SET old_passwords=FALSE; ; ^6 F4 t$ Q, R9 P7 o. p8 }
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
) M' w! Y) B: ?" X/ u5 rmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;0 i! p T8 D5 e: F
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) # a. N/ T8 n9 u x& ]9 d
" X( o1 W' B0 h6 y; p. B
閮剖靘撖蝣:) u# ~2 Y# X8 l" n! x& J
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭. i! V/ S( Z( X F7 |, s
mysql> flush privileges;, V8 r( B) W! G- } |
. H# S0 L( u3 i E. I& ^
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
# q7 y+ x+ j# o4 g, K瘜冽:; D0 z" A4 r; _% F$ x8 U
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
! ^- Y8 ^' \; K% p鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:$ U. i& Q5 ?( {" Z [* ?
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
2 q m4 d4 f1 K k. Fmysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers' @. L' w% C6 V! ^! u# q9 D) u
:
: d6 d, |9 Z& t5 ~0 }/ }1 y( n% Z決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
/ I% X$ S0 O+ ?# C: Rvi /etc/my.cnf 乩:9 o V: e v4 S% q" }
[mysqld]
; N6 b. I% m% B0 v5 {& z- t- ~+ H4 E4 U/ J8 q
character-set-server=utf8
3 `( u* `& B. f! u. D7 ]5 Sdefault_authentication_plugin=mysql_native_password
; a) m0 k7 R/ q' B
( x" F; W) r4 s [* L[mysql]
6 B i4 N7 Z% W3 d ~6 H3 X: Bdefault-character-set=utf8
& J5 j* \8 ]/ ]: d% y9 x" d" h& v3 P' c4 Y+ A. [! F' t+ i$ p1 {
[client]- ?* M" H. M( U; E: } x
default-character-set=utf8* p: M* r8 Q2 o+ W7 ]9 f
0 H W5 V" e) a, J0 ]7 H/ ?
嗅mysqld! M1 U+ L, A7 g" M6 o5 X1 ^+ L
service mysqld restart
9 m2 _* I* P$ M/ p# A0 F摰!!6 [5 r" o) s4 G ^6 \8 | f3 G0 U
3 E% W- w1 L) W7 |( ~( L2 Z' X3 E. G' `: L _+ \; D
|
|