酥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').
; E" M) T8 u/ G2 Y( o1 L
/ S& p* M3 B! H6 Q6 R- H3 k% I臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.3 p: v0 V( e0 L' N; a
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)3 K7 j+ c ^+ R } s
餃叮ysql 嗅頛詨 :
0 P" X6 G) g/ M- j) P$ X) {mysql> SHOW VARIABLES LIKE 'old_passwords';9 `1 }/ d& \, g3 P4 Y9 d
+------------------+-------+
' f4 {" \7 z* P| Variable_name | Value |8 W, h& p3 u# t+ f" r
+------------------+-------+
- @8 k" p. T4 M0 p T( V* i| old_passwords | ON |! F9 \7 o! y8 X4 Z4 X# Y: T
+------------------+-------+
C* H! U# u6 D$ ]/ N% [1 row in set (0.00 sec)
( T3 v$ t8 [+ n5 b. X p
7 Q7 z- \6 o6 C1 nold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart& x" g" a5 d+ ? r9 W& w$ k# i2 l% r
mysql prompt銝頛詨:
2 H4 P, J8 u6 _/ @' \3 I C. emysql> SET old_passwords=FALSE; 9 j, y0 z% U' W& c( f) d( N- k! j
瑼X叮ysql.user 瘥撖蝣潮瑕漲:+ L& ]6 h1 J# B: J. L
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;3 H# Q# r2 ?7 Y# J& [
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
2 j: k0 \; w' Z$ M9 o( {
# |/ @# P/ ~6 f5 N" N6 K閮剖靘撖蝣:
- j+ I0 e' K. s7 Kmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭' `: |$ J1 z ]. R4 M: Y i& O) i
mysql> flush privileges;/ ~, U( H' t& B9 R3 b* p
# l2 p0 G3 P r2 _
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
& t1 Z0 ~; [# |. t. E7 j4 ~. j瘜冽:
' o0 a1 \, q5 j9 p憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================/ V& D: j' ^3 b) z0 o
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:$ l$ r2 W6 k" K) E8 Q N- i* q; G
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers4 ?: R' H2 y l9 v0 n2 Z
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
: C; I/ _+ ^. P* @:1 b- @% w5 h) c8 r* E9 B3 ^
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:" |( r* g. A+ m; |& S8 ^
vi /etc/my.cnf 乩:6 G( q" T d0 U8 Y+ Z# G
[mysqld]" S0 l* x b6 `$ i! N
1 T: g2 T* G5 G
character-set-server=utf83 R( A3 y+ j( ^) f4 h8 c7 Z+ T( A
default_authentication_plugin=mysql_native_password
& j. ^" ?* k% P5 |1 S. w7 Z7 |- N6 `/ ^
[mysql]' O. m! N& t0 j7 [" f
default-character-set=utf8( M# [7 K" B6 Y( s. X+ }3 `3 b
+ G0 M" ^, v" S: j9 N n) `[client]4 B* C9 [5 S! S7 X
default-character-set=utf8
& [7 x+ }# r/ \: N; ?
% C" b! H4 {. O4 n4 H8 t% k/ R嗅mysqld7 u/ Z/ F6 F# I: H
service mysqld restart `1 z8 x8 r/ E
摰!!
: @4 c8 Y( f' P% F. u* m) c& K' i
# Z7 C# s# B9 V' e5 H7 @+ c/ `
5 ]$ Y3 ~0 F0 z. L |
|