酥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').
5 ~6 G4 p9 ^1 D, j* P9 d
3 X9 K4 E4 V: t* }2 k臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.8 n; t) v+ f/ ~1 X
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)% ]4 I v: v" Z: t- {/ d
餃叮ysql 嗅頛詨 : + M) z l) O* i: S3 A1 F
mysql> SHOW VARIABLES LIKE 'old_passwords';
) S ?" j( W. h R4 y- u$ ]+------------------+-------+$ {- Z9 b! _" S) J W: ^
| Variable_name | Value |- R8 b7 t/ @- ], b5 u2 H* i
+------------------+-------+
8 _$ Y! y& q1 l; C: C. w9 V| old_passwords | ON |. m5 h2 K D* H- Z9 z. o% `1 W
+------------------+-------+
2 U3 x6 V, R) ]* f1 row in set (0.00 sec)5 h g7 V& t% T8 ~8 x! @3 g
. ]5 ?- `9 c, K9 S5 `
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart. ?+ S) p& A& _5 o# }
mysql prompt銝頛詨:
/ g) J9 |, Q1 b8 b4 Wmysql> SET old_passwords=FALSE;
' F* H+ \" D8 g9 a5 U/ I瑼X叮ysql.user 瘥撖蝣潮瑕漲:& Y% R; D. h" a: g4 i8 l
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;1 A2 L9 B( f6 [8 k, a
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
0 W5 P4 C0 ^- f7 I* `. p1 m
6 } ?( m$ L7 m( q; t @1 d閮剖靘撖蝣:8 S1 B: A5 ~/ p
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭8 ^% G; E, [3 w) e8 k4 N+ [
mysql> flush privileges;
! X' A4 z9 b: f$ G
7 O. R8 Y$ c8 Z頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
) [8 r: C) \# K4 e- c9 A( w& |瘜冽:
8 b) Q( F! L) y, U5 e. |; @) h憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
% i9 H$ r0 ?4 w# u( i: o {鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:/ W O, b7 H9 N* u
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers% _8 k# t! K& Q! [& h
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers- O5 \" ?* @8 z0 M
:1 u( D7 m% c) p) D/ O
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:2 t0 c; ]+ e) U, s4 B
vi /etc/my.cnf 乩:
' c0 U: D" H% b3 O! f4 ^[mysqld]
$ Z4 h- g6 n% z: Y
y0 E' @: Y* ?+ |3 S- R& Kcharacter-set-server=utf8; L L! t! U+ b/ `" M, f' X e" ~
default_authentication_plugin=mysql_native_password
8 l, g* b$ N Z: y7 G/ N1 U' D, e. }% N6 o& \9 b; U; J
[mysql]
$ W; Y" d" w" D+ [" r! udefault-character-set=utf8
- A& e) R& B. ~) f: @6 f8 F! m c c. V2 s& v8 f. A
[client]
$ ^/ D; W# n6 j3 k, {. Fdefault-character-set=utf8
: \4 `6 n9 n3 Q0 g* z0 H- q& D) P1 c1 i: j. p
嗅mysqld
! I2 H* I# E* v' H( Z; w- Mservice mysqld restart
% P% m9 I( D, R) T摰!!
1 I( P: ]4 Q! M3 ~/ d6 v
( y+ e! c% M6 v
5 _9 S1 i- q) f: X |
|