酥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').
; i8 I0 ]0 N- c9 @
( v3 k" l6 m2 b" p) H$ w7 V+ g- ~臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.& ]) W/ P) D: j3 Z5 ~) x4 t6 b
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)- E1 q. b/ y9 @. N( Y. B6 E# ?
餃叮ysql 嗅頛詨 :
# H F# j; L9 x' S- B$ e* lmysql> SHOW VARIABLES LIKE 'old_passwords';. Q" O* j$ G7 q; e2 v5 x9 A1 r
+------------------+-------+/ K. N" j) D& I/ x$ F; X% ]2 r
| Variable_name | Value |
, G: q- ]" k* W/ H, J+------------------+-------+, n9 | x7 S' s& O0 |6 x
| old_passwords | ON |' O. O6 Z* f( C7 t* @% \* W
+------------------+-------+3 t9 n( F. L$ Q* N6 r
1 row in set (0.00 sec)
& H6 K+ r# l: u$ X6 y# w0 H+ A
^6 o! L% U _& _7 r& b: H# N' mold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
4 }4 H* L& z" E! I7 S4 V mysql prompt銝頛詨:( E0 @ N# s/ O2 n, v/ b
mysql> SET old_passwords=FALSE;
- e# k' p0 ?2 \瑼X叮ysql.user 瘥撖蝣潮瑕漲:
. C- i9 k( \+ n2 r3 \& S' s) g% Dmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
5 o$ G6 H8 r Q; j, P0 ^ _0 d憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
/ F+ U' x$ o" e# k( y6 L( i |" X5 L
閮剖靘撖蝣: ~3 n6 Z: @. r4 V4 ~2 m
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭7 H0 E1 |* Q2 n! b1 u
mysql> flush privileges;
# N" r7 L2 _8 @4 u9 V
9 Z( [* R* P. V& ]$ E/ t2 u( Q頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣+ I- _8 J3 w" a$ K0 h
瘜冽:
& y% p) J! b# E) o! [憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
) M( c' W" `+ @$ b- e8 W鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
0 q7 @, B) U: ~. g- ?( Vmysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers+ J: g! k7 a$ O: \" r; I
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers5 f4 {- O! A# X& I6 _
:; a/ `8 @2 m8 \( t. |
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:% l+ N6 \. v$ N# K0 K( `# j
vi /etc/my.cnf 乩:% \5 j# a/ F; E" I* K: ?
[mysqld]0 _% n, }7 d+ b; s
h1 \7 h0 v. r$ h. N& c
character-set-server=utf8
) X% g0 I6 H! \* u* Bdefault_authentication_plugin=mysql_native_password( n0 y3 W9 [. |6 |, Q/ ?/ b S/ ?6 A
7 C3 }, _5 m/ F$ X7 R3 J
[mysql] ?, J% P; a3 i: f# k- @; C
default-character-set=utf8
% R6 P! f7 G |% W. g6 w7 I! @) _2 f/ v) |
[client]
- K6 n6 W% E" I, ]( j/ ~, `4 n- zdefault-character-set=utf88 g4 C9 ~: S/ b) {: P/ |" p _
+ b2 x+ j% {, V1 Y嗅mysqld' {. S1 e; n+ o9 `" ~% e
service mysqld restart
. l. ?" X \. U4 a) c摰!!* n* u! ^# q# P9 n W7 l3 k! j
" H& G; G/ ]) y2 e: O' i5 `) x% T' t
! V" t6 @) V. S) f |
|