酥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').3 {6 e0 X+ P- `3 c7 G9 _. N3 v
* I3 N5 ?+ r% H! g$ U. I
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.6 S: y, A4 T8 f" P- W
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
% t* N0 y, u9 C+ y) V6 p# C餃叮ysql 嗅頛詨 :
& Z+ Y: O( p% K# imysql> SHOW VARIABLES LIKE 'old_passwords';9 b g) D& P( x' F! a* i1 Y
+------------------+-------+ R& e2 ?; h; l8 R
| Variable_name | Value |
: Q! n9 b9 m, d9 Z* f& ?+------------------+-------+5 `2 U$ b. `1 B. N* y
| old_passwords | ON |
! F' @* [- k' b c+ T7 K+------------------+-------+
7 g7 W0 m" \3 e' a- d1 row in set (0.00 sec)
& Z5 x) @3 Q% r/ \9 z& @* d5 y9 P4 u, S
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
- q( Z+ [& \+ `$ H6 W$ y mysql prompt銝頛詨:: ~1 h- k) P+ C9 L" H9 Q5 @
mysql> SET old_passwords=FALSE;
8 `+ S0 A7 V9 w# g3 b. Q2 u瑼X叮ysql.user 瘥撖蝣潮瑕漲:3 X4 X2 U# ]4 r' w' T
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;; w j, b6 ~/ u/ m" O$ v' I6 [
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
1 s6 G' M/ ]' O# _' R1 u
2 G; `- Y1 Q: l1 M# x閮剖靘撖蝣:
" b" B5 F8 L U/ V7 jmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
$ s. ?* s9 ?' x0 d/ smysql> flush privileges;; W" T+ c5 R( o$ D6 |
; }' s' R$ Y: n' q頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣8 {; C! s! Q5 ?$ F& r- @
瘜冽:
$ j$ f' a7 a8 V憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================( e% Y( v% }/ j
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
, S7 o, @1 q, f% S' q, L( ]# O& omysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
9 q3 {: B2 l jmysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
& s% W; Y$ ?& U' v2 L$ b9 X:
& {4 R% s& }* T2 n1 O- _決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
w$ ]9 K* p& t7 s: `0 Svi /etc/my.cnf 乩:( D( {+ }. I8 V3 {, ~2 v
[mysqld]
) T0 k& E' F, h- ^1 `6 d. l- J0 M" ^" z$ N
character-set-server=utf8
* g' f* W& D2 d, J% cdefault_authentication_plugin=mysql_native_password; s$ N a+ C- Z& f
. c, h" A6 t7 D+ I( [$ I
[mysql]
: }: ^- {$ k7 ?" f6 D% xdefault-character-set=utf8
3 L0 p* a. [' z3 @" E% ?, n3 ~5 ]- `, ~- B
[client]
. B# w( r" F; Q R1 Ldefault-character-set=utf8
* s* U* y3 s8 y4 `7 X9 T
# w- ~3 J! k- C d. I嗅mysqld% m! m8 a: {! j. \7 A
service mysqld restart
0 c* V. P$ r0 H! u* x! Y: T; P. ]摰!!9 D" b$ F) ~. E1 }4 ?2 o1 z6 h2 m
- p& Y. D; Y' W l
% v1 V5 t7 r' F$ P s* _ |
|