酥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').
1 l) y% \, e Y2 o' ~1 r
% j9 N1 k* f% s! i" W! u臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.6 y- Z& {8 c* y( t
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)- z. a8 r0 t$ a
餃叮ysql 嗅頛詨 : 0 o8 f. i( g5 i
mysql> SHOW VARIABLES LIKE 'old_passwords';
9 O' r, r# S5 D: c6 G- @0 d+------------------+-------+. V& X& H! q; |/ V: Y& ^
| Variable_name | Value |/ B; l9 [0 K* h/ O& B* H
+------------------+-------+
! V% d+ r+ b: Q- v* V$ U# C' X| old_passwords | ON |
' z t; _. v3 S. ]# x+------------------+-------+
3 r+ Z5 V& A0 P5 T9 ^, m1 row in set (0.00 sec)& _1 N+ ^- o4 ^0 Y/ @
. z6 a5 o% N; ?6 p* M2 j
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
* b3 O6 G7 o! E! p3 M& K mysql prompt銝頛詨:
, i$ x7 A, u( L" Wmysql> SET old_passwords=FALSE;
) }8 j* c" c1 l2 P Z瑼X叮ysql.user 瘥撖蝣潮瑕漲:, ~- u4 h$ `, o0 x# W" ] q" @
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;/ }, \9 D3 ~6 Q2 ]- f% p
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) 7 G. Q' s0 ]2 U5 n! A5 I
: n2 [! T( d" _( r) a
閮剖靘撖蝣:/ a/ Y' f) r) O
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
s3 u2 D. T5 t; nmysql> flush privileges;% e0 @0 y5 ^. ?- S
' k+ {( y$ ]1 Q( ~- h
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
L7 C! `) M! W+ f3 u3 N' x瘜冽:' V7 V7 W! W# V- S6 ~
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================3 z) k; m, Y$ x# [( G
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
* K7 y: J8 J% V( R4 \/ `2 ymysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers8 ~! z/ d+ R0 O% _7 M: U
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers* g. x2 q" P6 R9 {6 ]+ e
:9 @. o; X+ |) j: O5 Y# o; s/ z/ U# M/ d
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:5 h/ f+ M4 N+ ^
vi /etc/my.cnf 乩:
" m& W( A" B1 f! D( O' L3 O[mysqld]( n4 s& e8 e: N% e4 ^1 g
" W! ^% J$ Q2 ^' J* Pcharacter-set-server=utf8
/ Q, N& G6 @. B( L) P1 L- B( n( odefault_authentication_plugin=mysql_native_password
0 ~$ J6 T! x; Z' U1 F B, r6 o. T$ d u7 [/ I: ]9 }5 U: E
[mysql]
& i+ K5 n/ C7 }: I& z0 ]default-character-set=utf8, K1 g: g: z9 m0 K# Y4 x% K' s
3 |! {% W0 v* m0 X2 E[client]
; M0 _2 |. O' I! a- Ldefault-character-set=utf84 L r2 F6 d1 p
% P6 j3 r: o) ]; E' e+ u. W
嗅mysqld
3 ^" Z' O2 N0 {6 t9 sservice mysqld restart
' Q1 U" T7 d1 }; k! k/ O摰!!
% ^- K! Q% ~( F! g7 T/ H" z$ _% E: J4 |# X% V L d+ g
, s5 p% [' @+ {+ N |
|