酥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').
- ^9 c. \6 J+ a- q/ I: V( J, ~
4 R+ ]% @& q4 |7 ~8 _臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
# H5 Q8 C6 q# L5 H5 S閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
; ]/ \" S c, y C; s3 M% C% N5 b餃叮ysql 嗅頛詨 :
+ |6 ]) M, N( n. k8 V& }- mmysql> SHOW VARIABLES LIKE 'old_passwords';, H4 a$ G5 R- P& j0 F: K
+------------------+-------+
( m7 E0 \' U8 S" P$ ?7 G) g7 y+ k% N| Variable_name | Value |, {( E( @2 h) r4 M ~
+------------------+-------+; ]# }) F0 F, J8 a1 W4 l3 z
| old_passwords | ON |
6 F: r( H. {* ^% _8 q6 H+------------------+-------+( S+ N! ?0 `; w8 |' ^' V/ x3 k. }
1 row in set (0.00 sec)
* {* R1 C! F7 z& X" Q& M. x/ ]9 b- d7 E7 `! w( @% m
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart/ A' O1 J& a N6 E4 J
mysql prompt銝頛詨:+ M+ J# h; N: ^( v, Q8 ]1 m7 Q
mysql> SET old_passwords=FALSE;
( c# K7 g9 s/ k& }瑼X叮ysql.user 瘥撖蝣潮瑕漲:
- u+ p4 X. U- q: T3 }mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
O `6 N- l- u2 n0 \憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
$ U8 k+ A: C8 q1 f% G; l W. g" e! Y3 S
閮剖靘撖蝣:
' d9 \% Q+ T+ u# r* i" rmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭3 K" V9 w+ u3 N* B- Z* r
mysql> flush privileges;
7 q- ?: U1 {4 |2 S: x/ d1 \( i: n3 L" ~. |5 m& k
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
" s$ u/ w: h# b$ g: m7 b" D瘜冽:
) `0 z" L; O/ n* X- P' k憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================/ ]: ?- B- ~/ n! t8 f* `# M
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
$ |( y; e! c& B* {. Q) R9 xmysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers' z7 O* b# V; h
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers# _3 D- u# O! ]" ^: A
:
3 A* @: u, n4 H2 x8 g3 Z" m決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:( N& Z4 l8 M; K3 [
vi /etc/my.cnf 乩:$ f# V$ p* y) w7 E- i( M- x
[mysqld]
* Y/ Y% S O! M5 u: s5 L2 O3 V7 l
character-set-server=utf8
$ ]; R# O) q: b% t$ Xdefault_authentication_plugin=mysql_native_password
, j* H: l0 y, Q# y8 `! I- X! Y6 X
8 }6 m& Z1 R; ]) K7 ^ ^[mysql]
. Z t/ v1 l$ jdefault-character-set=utf8
8 U r; M+ p2 c9 o6 H8 J( J1 T! i1 O! U; \ c
[client]
3 f3 X2 g, h+ R1 l6 fdefault-character-set=utf8
. x9 E* v. [, Y. `! G& w# |8 T4 u3 ~
- \3 ^* R+ A6 d/ P% u S; T嗅mysqld
0 z! m& N( v, ?7 ?8 v# Qservice mysqld restart1 b5 Y+ O" W6 b- ?( i% O
摰!!& V+ [2 D, j& R+ F0 I6 s
" }4 K& o2 L9 g* y
! y+ U0 o' p/ w+ A1 j6 b( U
|
|