酥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').% P0 g. `3 d6 O& N
, i, C% d) p5 b, L! j5 [3 R
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.5 m+ L0 h/ l+ L# m+ g
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)3 Z7 @7 v3 ~$ X1 @+ o* y0 E
餃叮ysql 嗅頛詨 : ; j' j* [( M6 ?, n. O
mysql> SHOW VARIABLES LIKE 'old_passwords';
; r& r& P0 i8 L) @8 g/ F+------------------+-------+3 _- d' ?! f$ p5 n% r
| Variable_name | Value |: a7 a+ r% T2 \; n+ t8 f
+------------------+-------+
- C C: A# a- A( o9 E0 R| old_passwords | ON |, Z+ ~; u; f* N
+------------------+-------+
; f* b8 Q# A9 s* m) v( K. Q8 a1 row in set (0.00 sec)
- ?1 R7 p% ~. `* ?. Q8 X! j! s! K
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart3 S: h* @' ]. i1 e
mysql prompt銝頛詨:
. D& X' M1 T. ? N% xmysql> SET old_passwords=FALSE;
& D: c) C4 W- w; {6 W. J& j瑼X叮ysql.user 瘥撖蝣潮瑕漲:
% z& l1 d( p& k+ O' r8 Wmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
% Q2 Z' R5 u3 W憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
9 V5 q- s/ Q' r9 s6 x! f: ~' O0 \( x) V7 [5 G. h8 b
閮剖靘撖蝣:$ O: Y3 r' p( C) t4 B
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
4 |" _0 N; d) q1 ` Dmysql> flush privileges;
* N$ W: k4 l8 a1 L3 G- I6 W3 M# t0 _. L
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣. ^8 P# ^( t3 L( S% W" g, d/ g
瘜冽:
* T4 ?* A1 ]' C& W% `憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
. x' w- @& W0 Z& X2 M. I' x鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:* _- B3 L. a6 ?8 s, W" q
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers5 { d9 u( ^9 d: Z. `! X" Y
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers( y7 `, q w) k# y
:
+ _. u' k4 P1 c5 n8 c決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:/ B. }) z- F) {1 q9 P
vi /etc/my.cnf 乩:, g) x4 x% [9 y% _
[mysqld]
x5 l f6 Y" B$ R3 m, X5 y5 C: ^& k/ O' s) T5 Y- Q
character-set-server=utf8
9 J" V, f3 _7 S5 \default_authentication_plugin=mysql_native_password
& |8 i2 I5 `; d+ W' W o/ s3 C j2 N
[mysql]
+ n6 b4 P. e8 p" u) T: O( e o. B' h \default-character-set=utf86 ~2 y' N- y; J2 p1 G+ v2 z, v
9 `5 E7 H" E1 T1 Y2 f4 ^[client]
2 |7 q. Z6 Q9 Ddefault-character-set=utf8
. r1 S4 U) ~" O/ A3 p
# U8 Y! R3 u7 V7 O# [( w9 f嗅mysqld: {1 v; Q" f5 e2 m, _
service mysqld restart' k$ \- w* g1 e$ G7 h
摰!!
2 g5 Q6 S/ f( c) u# c2 x- Z. ~- Q! X7 |5 a
. D& }! N/ I# w. k2 a) J1 k
|
|