酥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').: n5 ?% }. x+ Y9 P3 W F! n
+ ^, \' ^" x& L( V) W
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.+ V7 S* Y" A% Z6 _1 f
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
% k& B% ?( t( n: _# L. s餃叮ysql 嗅頛詨 :
" P2 E- Q3 M- L! d$ ~mysql> SHOW VARIABLES LIKE 'old_passwords';1 F' E7 X" }, {! L% b8 [
+------------------+-------+
3 ^1 T: q+ V4 i/ y* d' i( V; h2 q% ]| Variable_name | Value |$ O4 f- Q( ]3 M# n
+------------------+-------+
: [" ]' R& A6 D| old_passwords | ON |
, U4 t) t: H) e; }% c4 N+------------------+-------+% b4 b* C8 ?4 H! x3 f! f4 g4 x1 [- r
1 row in set (0.00 sec); L* h- p: n* ?/ R& T/ _. g9 S. l
% W! a/ X7 ]' S) N) `: D6 B2 J2 m
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart6 f6 z$ F4 }* D) L/ S
mysql prompt銝頛詨:
( {5 G. x8 Z* Imysql> SET old_passwords=FALSE; $ Q# V2 Z0 i9 E" a' B
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
/ @! C% }8 r! Smysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
S' Y5 H* |9 Y: o! @" H, O7 D2 C- [憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) ( |( D% p* f L- ^+ f/ F) |
7 {/ s" M* E9 b閮剖靘撖蝣:* ]8 y2 @$ _4 c& p3 L/ K* E
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭. o: R- |' G0 H
mysql> flush privileges;
7 P7 H7 J+ R6 V5 ~- M3 D q3 b3 r& f: f
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣1 N1 o9 A0 H1 b$ e
瘜冽:
% l/ U" t3 \9 e, Z, u$ d憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================$ g4 b4 a6 W$ H _' ?' u! R2 {
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:. ?3 b+ {; F0 i: `4 C
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
- |3 G" }' Q$ |mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
- n* Q+ ~& e- P:
5 E) x" x$ v( i m; x1 c決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
0 w& |9 q7 J# {) s: T) h2 _/ g/ fvi /etc/my.cnf 乩:
~# G+ [, N+ j6 [3 M[mysqld]
% X, M; l4 Q7 f4 w U
, N; ]7 R. B' s4 K. S& U6 |character-set-server=utf8: N/ d0 k$ H2 Z; a, Q, `8 z( z' K
default_authentication_plugin=mysql_native_password
2 ~5 ] w) b/ ~" b; t& S
6 m: S8 |0 q/ L( M* T+ E5 o+ f[mysql]
: C. Q T# w: g* Ydefault-character-set=utf8
2 N: v2 s9 g1 k- J: B1 t5 D8 }# C3 i0 G
[client]! m8 m) F3 ^2 N* M! c% {
default-character-set=utf8* ]" Z2 `7 @( s- o6 ?
! S" j! N$ Y$ i4 Q" K) ~/ Y
嗅mysqld3 S) m& ?1 q; ^+ V6 a
service mysqld restart% W4 o" V1 y5 C- B6 D9 e0 q
摰!!& N2 G' e p3 S
5 b! N/ Y8 N0 m1 e1 x$ F, ]7 G: A$ B6 ^) l) E
|
|