酥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').' v% \* ^" R7 q: ^0 C% d, p
# I y+ D. S7 L- G- U$ |
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
0 x+ S' G1 P" D/ F. ^6 B閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
0 t, m+ X+ `0 C3 m! S0 |餃叮ysql 嗅頛詨 :
* a* p6 j1 ?9 s- R5 a* `8 }6 I6 Nmysql> SHOW VARIABLES LIKE 'old_passwords';& W* b4 D* [* n t N/ r$ d. v
+------------------+-------+% [0 O5 d' F. q; b! a
| Variable_name | Value |
2 g- M7 j+ X$ O; k; V3 Q2 C9 ?8 F0 x+------------------+-------+
4 s5 e, d2 t: \% y7 B( }" k% ?| old_passwords | ON |
7 m# w3 N- c* A( k+------------------+-------+
6 L1 Y2 n# Z, m- [; z0 k5 P1 row in set (0.00 sec)
2 X) o9 q" F, I7 m% ~
5 S& g! c& `3 T! R3 fold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart) t* I- r5 J! ?# \
mysql prompt銝頛詨:' T Y8 j7 h$ e
mysql> SET old_passwords=FALSE; + G) m) a( Z4 C3 W5 {' r
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
7 j2 h5 ]1 b" d8 Pmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
( b) u& N) s3 y m憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
: C; f0 Y. g& u7 i/ _8 I. J2 X6 V
5 |4 U6 z" \& t) p- _5 H9 `5 ^閮剖靘撖蝣:, k$ F$ s3 d" Y
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
! P3 N9 g3 R# [. B$ ~0 {mysql> flush privileges;
6 }; T# E- {1 `" g5 @' t, ?( A1 s- m0 E" t5 s, {
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
* a1 P0 C' P9 v. N! ]2 @瘜冽:
: g' h9 p8 @) k# A9 g憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
. g) h7 m% n. F" g' L4 t鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:; X! H1 B+ K+ V7 V) A) j& y
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
/ A+ p3 S: @6 C, a9 N$ Ymysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
' P+ r; W3 e/ T# z:1 y* A7 O9 ~* ~: j5 s. p% g5 | j
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:) b, _" w+ M1 P1 Z
vi /etc/my.cnf 乩:& ~% F# M2 v5 O8 C' e* d( g
[mysqld]) X6 r. y) N2 p1 ]2 ]. _7 _/ m1 l
) J& x1 V% k/ k$ z8 v% n+ A
character-set-server=utf8
7 t l+ i2 f8 ^8 l `7 x9 {" x1 y* p6 Tdefault_authentication_plugin=mysql_native_password
& d% V; {. n, W4 {& B; m9 E9 g/ ?4 b j, o: n
[mysql]' i9 G! b4 y$ ?5 F9 n0 \) E6 |* x
default-character-set=utf8
; J* S' z4 q$ N: j( \2 U6 i8 I: e* O2 A; n: w
[client]
5 P8 I$ P$ o0 B& |" a3 Wdefault-character-set=utf8( {+ a+ e8 b8 a$ d
0 \! a0 k* c6 _& ~* T6 }8 X
嗅mysqld; a% O+ @: c2 r. p, Y5 D
service mysqld restart7 t" n; e: i! R0 x8 o: e
摰!!1 b" c# D" I8 v! g. q; a
$ W. R( v- P2 `- B9 G% D
b) O( v& p7 y/ ]- n( B. o
|
|