酥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').' I% j0 g! b p/ D% c. r( m8 O3 d8 S
! Y! j* c' { N3 Z6 a! ]. g
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
! A9 ~! v. W2 _1 ~. c$ d閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)& K1 V" E. X, P
餃叮ysql 嗅頛詨 :
2 F# {. Q2 ~0 f- emysql> SHOW VARIABLES LIKE 'old_passwords';- X* ^- `) H1 d, X& M0 m
+------------------+-------+
* D4 g9 o' b% _( F| Variable_name | Value |( @9 S" I; H, M) t
+------------------+-------+
* W g2 E5 u/ o! V% R& h| old_passwords | ON |6 Z* g$ ]( M+ D) L5 p
+------------------+-------+
+ U% n1 Z# `5 s1 row in set (0.00 sec)
4 J# u0 { f; {7 ~+ g& h, z! r9 n
, ]0 N# L& O, g3 W& dold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart6 w8 l5 z- Z8 B! N
mysql prompt銝頛詨:
: f- p5 A# |% S4 u2 ]4 _2 hmysql> SET old_passwords=FALSE; D9 m# T' B$ m5 `4 E7 Q- m
瑼X叮ysql.user 瘥撖蝣潮瑕漲:+ R1 |) c: F8 Y6 K! L
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;1 v* `, ?& [# ?4 k! w& s4 p
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) 5 m( f: C# [& _- T' q
! ~8 K6 q8 k0 D. C2 }, x, R
閮剖靘撖蝣:1 n( X1 U- c4 C7 x7 F& q
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭+ y5 _" L5 _: b$ _: g2 U9 _/ [
mysql> flush privileges;
) F0 N3 r( c8 Z C) q& U4 K( K' E- _2 E5 c/ @5 s- J! B
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣( T! \0 Q" k: @& G$ v, B/ d* B/ X2 J
瘜冽:4 G* I" w; T+ s
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================6 h' Z7 L0 _3 T" c s0 y
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
5 {' J8 ^! U3 `0 n+ K; }7 Fmysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers7 j+ W; U' K# H* w4 i+ X8 l
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers( \, {1 ~9 g$ g4 j$ G6 d: t
:
. z' F0 j/ w9 g+ c J1 ]" t8 E決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
/ s7 b+ X' S6 t& z: S/ H+ M- ]vi /etc/my.cnf 乩:1 g* `- { b- h1 y x
[mysqld]
9 Z2 Q) H; n2 Q3 T+ o9 B" ?3 v7 v- M* H' c
character-set-server=utf8
0 \5 B% L( r' G% Qdefault_authentication_plugin=mysql_native_password
4 z5 R( s- O6 D' c' h! `9 g5 H9 ^; {: C
[mysql]& f& x Z: ` w: G5 F6 z
default-character-set=utf8
7 h( |! B9 u1 i$ a# b8 u6 f: v
2 f L9 a# t) @ n$ G' M m, N[client]
: g. V2 D0 g4 a: S! R7 L; ddefault-character-set=utf88 G& K' I: [- Z% ]( h
( d& d% M% `, A# F* N% t& m9 K. h0 _嗅mysqld
, t0 f. g8 C6 qservice mysqld restart
5 ~. n9 U$ x0 t+ w' i0 p摰!!
/ k7 X" j0 l5 {; R$ Y; x3 m
" L, _. K& P* p8 ]* Q/ |1 L' ^2 X C E( G- E
|
|