酥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').5 `1 _" f1 z8 `" l! }& l7 M. T2 ~# w
; e. @3 \/ q5 S% A: n- P7 N
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.0 ~8 M! m5 \) R* ?
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)" Y% j! }7 G+ t, O4 ?
餃叮ysql 嗅頛詨 : 4 O6 P" K8 F% O9 S$ C
mysql> SHOW VARIABLES LIKE 'old_passwords';
. X$ ?$ P# h5 w+ J" e+------------------+-------+
0 R! d* I$ C3 _# Q p- L) ^7 A| Variable_name | Value |2 W1 |/ u2 A' [- g+ Z9 m1 Q; k
+------------------+-------+
+ e; {4 S( J9 `1 z$ m| old_passwords | ON |
+ y9 s/ h0 h/ v4 A& E9 Q% F+------------------+-------+& E7 @2 \# S& l2 n$ h
1 row in set (0.00 sec)
! M0 W; q. n) R; h8 o' y2 v4 z, X \7 j* m! \/ \6 ^. m
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart& s) |* @# q4 Y9 e4 P, B2 G
mysql prompt銝頛詨:5 B O/ A2 I7 l: k# C( j# o& w
mysql> SET old_passwords=FALSE; 1 c) w! m+ k+ J7 t
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
8 ?8 x A+ \% [5 }* I) ?( \6 b5 _mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
( p" Y& o2 D! m; j憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
( r1 A6 E. K+ ^: s( K2 g( B4 I* }
0 b p; W) T/ t+ b! E( y, k閮剖靘撖蝣:
! D* f @6 ^3 x2 E: S9 G" gmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
! Z8 U' v$ Z* O: S- y, C7 hmysql> flush privileges;; Y6 M( r$ s8 q& G8 u7 M
3 y0 Z1 e% r& |( ]1 L2 @5 a5 X頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
$ f: G$ u5 ^2 E$ z( j0 r瘜冽:% g; s) X0 ?$ T! ~7 E
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================6 S! @ J- }3 }; u/ c- S) f
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:; @2 u7 a! H7 F* O) @+ T
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers8 \' Y+ W0 x$ _
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers4 M+ d% x: D0 \
:3 q3 y8 x* `* N0 e
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
+ ]# k4 \' f3 _' F- nvi /etc/my.cnf 乩:7 g1 R# O3 l, ?
[mysqld]
- |: I9 ?# C! y/ @4 z# @6 p V/ _7 w& o7 Z
character-set-server=utf8
5 ]6 c" t4 M- G% M9 \default_authentication_plugin=mysql_native_password" [7 D; I9 c1 j# \1 f
, @" F" ]. e9 T[mysql]
) I6 g) ~$ r$ z/ I# o9 @+ Rdefault-character-set=utf8. t. G: N5 m; A2 h
3 a. k+ ]- L' ]4 W' s' u U8 m/ N[client]
4 S$ K% l/ X$ f7 ~# N& p5 w) ]default-character-set=utf8% j( A- @* B$ o
/ `* r5 x! U2 I* y9 {- [8 m$ ]嗅mysqld
1 g. G( |+ h8 o( R1 h8 ]" tservice mysqld restart
& [/ L+ G8 x4 f# o* a摰!!5 l+ {1 ?' h. ~5 [. \4 \# }) [
/ v( Y a9 T" q0 \
6 Y, ~6 _0 D1 N) i |
|