酥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' G/ U" m/ L7 Y: {7 g
- _ x+ r9 {/ p7 J& U$ X& E& w臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
3 V) h3 _" |) t4 r8 `+ t ~閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
& H- Q( m( Y& f餃叮ysql 嗅頛詨 : e. X& {. m; q$ s
mysql> SHOW VARIABLES LIKE 'old_passwords';
% T7 ]9 E, y5 T+ W+------------------+-------+
4 `: m h: i/ `; x" c| Variable_name | Value |& x9 n) N( }+ n% e3 R( D3 c' s
+------------------+-------+
, z2 c, M( O0 H& P/ h! b( F| old_passwords | ON |
6 _$ t7 b2 _1 v H+------------------+-------+/ D$ t7 ?" V, V1 o ~) x
1 row in set (0.00 sec)! C/ c8 s/ l* T2 v0 Z0 ?( Y7 q3 j N6 m
- I( Q7 w! J- C# u, u( R9 y. C$ [
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart! E2 h% }8 A9 s* H
mysql prompt銝頛詨:
2 K' c& F2 F! N+ I* amysql> SET old_passwords=FALSE; $ r+ V' D }) g+ X
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
# {6 I5 m: P- Z$ W4 I# M% P( qmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;3 z5 W+ Y" a& f2 } Z" W; t
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) # i/ d& |# M* A; ]) p" F( u+ R
" @2 N* E+ ^' o9 ^" I8 e- }6 u閮剖靘撖蝣:( l9 a& R0 G# o- q+ z, P
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
3 r% Q# t, t5 B. A9 {( Cmysql> flush privileges;6 m) t4 Q+ w7 E3 A4 A
) ]2 W. \9 [% h. n' v; ~
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
6 @( Z. b) y# w1 T* L% }% L* d瘜冽:% i: I( c% D/ ~6 |( L0 H0 K
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================& J; g3 G3 P8 c8 r( N$ L
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:+ |% T! e; u. I" g/ i3 F5 N. y
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
6 B1 e7 R* U1 W8 {mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers" o4 w0 {6 t! w3 I0 e- s% v
:
$ y; G+ k- J- } `! v0 {& Q8 N4 v. o決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
1 g8 T L, D3 X C) n5 Evi /etc/my.cnf 乩:
n" E J7 ~* T+ O& |' }% u+ i[mysqld]
2 V @3 J0 w: \9 C' ^4 h' ?/ j* j; e$ C- J+ `$ p$ u! \
character-set-server=utf82 @. V) g8 W$ p! O
default_authentication_plugin=mysql_native_password# I% B. S+ H2 t' h- Q6 D2 e1 E
' X5 A( a5 _' z( I# s
[mysql]( _0 Y- d5 a5 k, L. G: x
default-character-set=utf8
H* G7 ~9 S2 O; X, m9 p: g1 v# N) t4 g3 V/ R" l
[client]
# ~1 \9 T8 ]9 M7 A* z6 xdefault-character-set=utf8) @, l8 s' M; a- j B3 U3 l
6 n2 T6 X" l$ U5 B; l& y嗅mysqld" _" B$ U3 I6 D& Y5 i6 T7 w4 f1 {
service mysqld restart% L1 Y7 i# Y1 \. a' ~( d' J I8 Q
摰!!; W0 p9 r1 O4 O' H$ R+ w9 j! Y N* I
" P% F U; Z: g0 I) }# {
( a) ]# A4 H$ z
|
|