酥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').
* \; _) T p: L& V# H0 n! ?3 w, e9 T% y/ U
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
! ?" Z* Q2 D; \( u" S閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)$ ]% f* f' _* w& B: Y" T$ ~
餃叮ysql 嗅頛詨 : ' X; }. a5 s& t
mysql> SHOW VARIABLES LIKE 'old_passwords';
! x1 [ V6 J0 N5 I e5 n5 Z+------------------+-------+3 Q* C# J5 k+ I1 t
| Variable_name | Value |
7 X& m3 z7 p8 u. |0 m+------------------+-------+
6 m! M+ w0 u% [* c3 O; v& q| old_passwords | ON |
/ f/ t+ p/ E8 g3 Y+------------------+-------+
) O- W7 g+ y( D1 row in set (0.00 sec)) ^6 e7 O ^1 s7 l- ?) u' G
5 C- D. N9 g- ~, p, R. L, wold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart' t/ P% x; \1 o6 \3 y0 U. X2 z
mysql prompt銝頛詨:
5 L3 q) ~1 b8 q' _2 Y+ z* s& amysql> SET old_passwords=FALSE; 7 L9 [9 m$ H+ t+ h% g- I
瑼X叮ysql.user 瘥撖蝣潮瑕漲:* W N* `+ {! \3 B; w. U; b
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;2 |$ c. S. n9 G& `$ `
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
+ `! O4 M' \6 m4 {5 T* Z( h0 |+ N
閮剖靘撖蝣:; I3 d; w4 W3 _2 l" D' }5 g; {
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
( i/ D# [' a& O( k6 dmysql> flush privileges;, C+ o: w3 E9 A1 [. V& J4 y
6 N4 e$ B6 l l. d2 S) j
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
) s' s5 m$ T x4 K2 U7 r2 }瘜冽:
0 w" z$ s$ ` O; Y' R憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================5 a2 ~8 r" e6 w. m
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:4 n g5 u% e- S; ?. l1 Z$ |
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
. H, s# }" u7 o0 z$ G4 c* Omysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers5 w$ m C9 @( g
:) u3 K1 c7 k, H( k! w
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:* R' `) S1 l, X" N5 ~& [8 M" G
vi /etc/my.cnf 乩:' L0 h d# p" K) h# h% @) d! f
[mysqld]
$ R' a: C5 D4 ^0 o7 r* \. U& v8 v8 e1 C' x$ F
character-set-server=utf88 w7 t6 b3 X" D# _
default_authentication_plugin=mysql_native_password2 ^& f" N: v! Y# |: h2 A
4 g' `6 c& q( Z- o4 W2 p3 @/ A- j6 Y[mysql]- G/ E5 R7 q3 ~8 l# [0 X0 x
default-character-set=utf8
5 Z- |3 o @. d( L
2 P1 L& q+ S. T5 E& B, Y$ ?+ m[client]; w. _$ Q4 a9 P0 j, K
default-character-set=utf8* N3 N, S2 G6 K: V" z
; n1 L( W! C1 M* @+ Y
嗅mysqld% G, o5 c: Z! N- R: B6 H
service mysqld restart# t S1 q' y4 c. \0 z0 p# W6 _
摰!!8 Z& }# t% P. s/ p3 z& @
) w6 ?) u$ X/ ?# r. r3 T C1 ]3 H$ Q5 D; p& j
|
|