酥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').
/ g- T& c I+ k* n( a# s& F- r& g2 C& D2 [/ c% O- o! m) s6 k3 E/ ?
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
6 i+ p N: r6 x7 u! c閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
3 d) C2 N2 [& G! D6 _, A: U5 v5 Z餃叮ysql 嗅頛詨 : , o8 @5 k6 J4 f3 w }/ @
mysql> SHOW VARIABLES LIKE 'old_passwords';
/ i. E& h8 {8 E3 }% T0 v3 _: T+------------------+-------+
: ^/ m, T9 B' D6 t7 o9 W5 x| Variable_name | Value |
( L+ g- U. V: W, h7 `7 L' \8 `0 k+------------------+-------+
1 [( R. S% u. j6 J1 B% t ]. i s/ g| old_passwords | ON |- f/ S3 \; ]) ]" i ^: ^( o H
+------------------+-------+; @2 ^3 i* Z1 F" j( _
1 row in set (0.00 sec)
5 F& W7 ~/ Q0 u0 x9 y- I9 X& J6 Q+ x: g. ]
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart: q: o r( E' _+ i# n- X
mysql prompt銝頛詨:
6 `- E8 C, I0 I9 {7 i0 Kmysql> SET old_passwords=FALSE;
& f! {# h( z4 F! T$ l瑼X叮ysql.user 瘥撖蝣潮瑕漲:
}" n+ O5 X7 p% c; mmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
% X: f5 @1 i, }憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) * Z0 N8 g0 L5 B( X* J
( O$ p# u3 A* a/ `7 I8 F# C& g閮剖靘撖蝣:
2 R3 v7 Z% E7 c$ G5 p8 x0 nmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭+ w* P/ a1 X0 S6 b1 w
mysql> flush privileges;
4 |8 u- \3 U3 S* R' W6 C7 o; a2 y7 R
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
5 W5 I3 O" k( j! D* ^瘜冽:
+ W" B/ o, N3 q9 q* f憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
+ d. H* Y. a- n, M9 l4 e( x鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:# v* ]9 T0 c7 M, z# A$ I
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
% @* ]' ~: o0 S0 W" Y1 F6 l) \6 f6 omysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers8 H% T7 c- i. y3 }4 X9 I* a% L
:. z; q, H+ ?$ @3 k" V
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:6 `% P7 x5 K" d+ ^
vi /etc/my.cnf 乩:
X0 s# V5 K, p( W[mysqld]
- g* g8 S. d7 {1 L; {, t; j6 m$ r; d9 R$ }- R c
character-set-server=utf8! G l- N8 M/ n4 s5 H l7 v
default_authentication_plugin=mysql_native_password
b) u$ s; T6 d; r& G4 C( z% L
3 r+ J' u! L* v' L7 w9 w[mysql]/ {$ E5 ]/ E9 ^& Y
default-character-set=utf8% W. P$ i+ b( l( A1 e- d
, ^" K5 Y; r( ][client]
% M: c m4 c' N* C/ [6 j4 ldefault-character-set=utf80 K( S: q! e" `0 T) H
! O0 z7 P R+ _ T6 b0 j嗅mysqld$ V1 U8 ]9 S: k7 u
service mysqld restart
! T$ p5 u) ]4 z: {7 B8 S- P# S2 w摰!!( `3 i% m( Q5 E- R2 C0 d
; X0 }& p& _* m
9 R7 E) W7 j1 ^2 i |
|