酥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')./ V5 O* u8 {, o. h% q% U
9 J5 L- F- }8 i5 y, T( f臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
. B' x5 k4 m6 T! N2 V2 { ?閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
5 j, G0 E: {! u& i- ~, P7 a' C6 l6 U餃叮ysql 嗅頛詨 : $ R, h: V) c9 ^9 W
mysql> SHOW VARIABLES LIKE 'old_passwords';
0 M6 z" ~6 M* [2 ]0 c/ Z d) m" a+------------------+-------+% H0 ]% m p/ f
| Variable_name | Value |6 O; L Z( S3 C8 ^3 _8 t8 M
+------------------+-------+
' K& I! v: F) F1 q6 o3 ]| old_passwords | ON |
+ l9 ]% E! R" L2 t+ S+------------------+-------+
1 T n# x* y* M% q# d1 g' x1 row in set (0.00 sec)0 F3 U) b$ o, ]; d. p( K+ e6 W
% K2 k1 E; m/ {( g3 Z+ Y- L: Y; f. R
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
% F" f/ p& X6 o9 d% h$ w mysql prompt銝頛詨:
! o5 \: B4 f% u" Y) Zmysql> SET old_passwords=FALSE;
! h! O; x" ~3 Y6 a/ B6 r瑼X叮ysql.user 瘥撖蝣潮瑕漲:
. y0 v. q4 c k! C% b) Y( A2 Nmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;# v6 q' {- d( X: J& Y2 h
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
9 s8 a2 r: d% b1 a0 b8 a2 |* r' a1 w$ b7 m4 O
閮剖靘撖蝣:
3 {6 M3 Z7 m; d3 i k! b6 a2 Omysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
1 W7 _- q" x6 @0 H7 omysql> flush privileges;
2 a0 [. Y* d' u. V
) [$ p# |7 S* F! X- e頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣7 V4 t, @4 ]6 E0 R% ^' b" t2 Q
瘜冽:3 e; D4 e1 G+ K! [' S- {* b1 Q7 ]6 p
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================2 ^1 J8 @6 }) c p0 Y/ q: S- I
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:& k. t$ k. _7 E: }* v1 D/ ~' t
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers0 V! Z h' \! m- _; \" L
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
4 K2 D1 I: @6 E) b5 D; i:
5 S) s( X9 ]; H4 u決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
$ U; V! [5 n& O0 ~$ ~vi /etc/my.cnf 乩:1 t5 ^4 D& f' N: `7 T
[mysqld]
" ` n' S& A" X% b0 @8 f! k- y. {& E& e6 H! w8 b
character-set-server=utf8! }9 ?2 E; s& N1 M
default_authentication_plugin=mysql_native_password
/ j. b5 B1 g8 `% ?
U9 Q9 {6 C( [& {8 w[mysql]% T0 w# Z- N5 {! }/ T
default-character-set=utf81 {$ K: @- J, m( J
7 p' {2 \1 a/ a+ a: G6 s
[client], w& N7 p& [# n1 A( ^
default-character-set=utf8
" x0 ]4 T2 i3 V6 Y# U9 s) o, V0 {4 @8 X9 \
嗅mysqld
1 B. n, x$ r" Eservice mysqld restart, }: r6 V& j6 r( j& A& L; I! s
摰!!
% q3 V2 J Y& D* Y* k5 l7 E. z4 T+ m# Y3 h; h' l
' U, X2 b4 m9 T; r( D; u% V1 \- J) N6 v |
|