酥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').- U* H9 Z& g# F' N" W
* b# y1 F" m" D: v8 {, B6 P
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
0 z/ }% t& e K5 j$ s0 J. J閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)7 c1 { i7 K* [+ d4 s8 D- _
餃叮ysql 嗅頛詨 :
, _' ?( o# I! L$ fmysql> SHOW VARIABLES LIKE 'old_passwords';
1 \8 V" I. ^- C" y7 T+------------------+-------+
# [- g8 }# f$ N# u! }0 ]| Variable_name | Value |
! f# v, `( b# X: ~9 S: t+------------------+-------+
& p( K1 E0 s4 a' B) E6 `& M| old_passwords | ON |2 \/ e/ }) X- Q) z4 |
+------------------+-------+
" Q, Q9 o8 ^1 X2 u! f' n6 ]1 row in set (0.00 sec)
- B' y: m4 t; a. l/ u
4 r* o* Q1 W, R1 \$ c/ D2 Kold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart7 F j2 X& a$ t$ w
mysql prompt銝頛詨:2 r% _- R" V8 v) e' F
mysql> SET old_passwords=FALSE; / P! y% S7 n1 X; G
瑼X叮ysql.user 瘥撖蝣潮瑕漲:0 J8 g3 s2 l2 A3 S" \3 q) J$ e& J
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;. W; X; P% u3 e
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
0 n$ |* z0 t, G8 s/ B
8 m4 l( l! _. i4 ?5 [. W: e閮剖靘撖蝣:( u# y) q$ _9 M8 c n, K
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭 s0 i1 l% F0 V. u* I
mysql> flush privileges;) `0 \9 Y/ g0 C j5 A) \5 A
9 M1 h1 B+ Z1 n頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
5 J$ ^. L7 V5 \. p) O8 R1 a$ I5 w) p& E瘜冽:
. g" l/ J7 M5 E6 b# ^憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
8 L+ f0 \$ s3 `! P ~/ Z" |鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
; S: q5 \& _" U& L! f0 W/ R2 S# _( amysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers' V3 }- B' s& R3 G" [& l
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers4 h# r/ A( d5 w& p' J
:! e6 f' j+ I+ m. \& X4 w3 ~ I# t9 c
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
8 l' y( E( {4 G5 h" O! Cvi /etc/my.cnf 乩:% _2 E4 J% X9 {. M
[mysqld]
7 d5 N. ~) E, k# |. ?. l
: I( ~# g" t! F: P/ O4 g5 e( dcharacter-set-server=utf8
9 Y: d# A$ t# ]default_authentication_plugin=mysql_native_password# r3 N9 J# h- l% H" s; l" s+ G
6 c! w' C" \) N6 [ \' `; Q) j
[mysql]/ D3 @- Y! g. o# H6 V1 c
default-character-set=utf8
! v2 r9 P) z- t b) T; ~6 D5 J' f6 M' S. F9 x0 K' H, F
[client]
' _6 ^. }( _$ w- \# W( M5 ]$ }default-character-set=utf8
, P* c( u9 k. c: T8 P
+ G+ s7 N6 M0 I嗅mysqld
& z0 I& M0 Q& k# xservice mysqld restart
7 P( k7 W0 y! }/ \8 s摰!!
( }1 o4 y9 o: ?9 H1 L( P, x4 E& e' }
2 C- p h" |- r4 N
|
|