酥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').
- u; ~- Z0 S, d7 R7 G3 i: e: `& Z& a( R% g* e0 @
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
/ _' `( F5 O& e9 E, x# Z閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73) _% K- `3 _7 I* h$ h3 \: [( Z" R
餃叮ysql 嗅頛詨 : s% y; W# }: p
mysql> SHOW VARIABLES LIKE 'old_passwords';$ A- W, }8 g6 ^+ o8 @6 C4 L% F
+------------------+-------+2 g$ @7 V& Q1 |1 M
| Variable_name | Value |
! ^1 g a# _4 R4 ]9 i2 ]! d w+------------------+-------+
; ]1 a6 h3 X# D A- r| old_passwords | ON |
. S: [$ P* q: l( P5 C% ]+------------------+-------+; i L2 s8 \3 C3 y. `* C
1 row in set (0.00 sec)
( d O" A) c6 U' I/ i+ ?, b* y& u6 ~2 d! \# P, T9 _! K' l5 v
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
: _# N2 I8 X$ Z6 M/ j- h( h2 D mysql prompt銝頛詨:
: L# ?6 `9 e' ^6 pmysql> SET old_passwords=FALSE; - j1 E- `$ Y |
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
- u# b- X {& z" [3 X1 q, Hmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
, ]2 p* O3 Y( a7 p S憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) ! R3 W1 }' P$ B
4 M, I) a& l& ^. b3 w" H4 Z閮剖靘撖蝣:, B7 \, s5 E7 F# T- M8 B
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭# k5 S" C) Z2 {7 Y' U: K7 @$ y
mysql> flush privileges;
5 Q- n8 [. E H7 y, V
( B" t/ D3 N, j) r$ `! E頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
9 o3 u/ j$ }* Q3 ]* m) ~瘜冽:. w9 }9 r7 y7 B: p B0 D3 `9 v" [) U
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================& o& K* j" [4 s! }; Z" P2 P
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:, Y) u+ [2 Q0 A# a/ x( ^
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
# ?6 }4 Z$ @; {9 b$ C8 jmysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
0 \# s# V6 G, \" W:0 k0 X4 W! X. Q5 H
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
* l. o0 \; l# ]7 Kvi /etc/my.cnf 乩:
4 m4 w/ R4 ?$ G4 c' N( t* l) U7 @[mysqld]
* U) A. @9 }7 g# k' e) u0 W; I. G! H) |% E/ @/ M
character-set-server=utf8$ O/ ], Y( q: b) r. }; T
default_authentication_plugin=mysql_native_password' H/ Z, X) j/ m9 ~4 D8 c
& g" i M6 F0 m/ F i5 I6 h% r4 d[mysql], I3 x7 {: s+ I, h# i$ n1 J
default-character-set=utf8% _+ W& y) b5 X4 ~1 u L7 u
9 _1 ^5 S R- z W
[client]
' I- a8 f( u' g. I6 K0 v6 i8 fdefault-character-set=utf8
1 |! F$ ?+ t; L: q u/ i9 a. ?- d5 B) j( p
嗅mysqld
% ?" E: J, \/ K$ w# ]' V. jservice mysqld restart
# I, m" o P5 [9 M摰!!
7 w* W' s" x+ g! r3 W; o( U( x; D/ f. p
, |+ z" g: `1 g- s( w& u1 p |
|