酥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').) A" a3 z$ o( `
$ m; |$ I% u; _# D- G2 M0 D5 P" @4 }臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.) x* z- l! b2 m6 N
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
" l9 v$ R( C8 v# @7 D, `餃叮ysql 嗅頛詨 : ; f3 P1 z& b) n' p+ E. y" q
mysql> SHOW VARIABLES LIKE 'old_passwords';$ a0 y) ?) t9 X
+------------------+-------+3 {4 W. w' `& z1 b- F6 A
| Variable_name | Value |
% N: ]0 y& F# l/ I+------------------+-------+
% L0 q: ]4 h- O- Q& x| old_passwords | ON |) b2 |1 a7 l# A0 k. P c
+------------------+-------+/ P. e7 i- b+ _
1 row in set (0.00 sec)+ Q9 f8 c; k" K( o; }) G4 g4 _
3 j5 W, V* m/ |9 h- u6 E3 [old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
3 H& f. |1 I& f. ] mysql prompt銝頛詨:
* M9 i" l' m6 I1 ^6 n# Hmysql> SET old_passwords=FALSE;
: Z* l8 n3 L* _5 ~' c/ _' ]瑼X叮ysql.user 瘥撖蝣潮瑕漲:) t7 \( P4 ~6 L' @8 y b# p
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
' u" \ M7 C; y! g憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
9 Q, P0 B+ g0 I/ @3 d! c, ^" `/ U# H5 b/ X
閮剖靘撖蝣:
/ [- e p# L% E6 T } p5 n( d, Vmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭: Z$ B! {% y# X% y% U/ a: \# F
mysql> flush privileges;
7 y& } a3 Z3 Q4 n/ R
' t& e+ l8 w$ x$ z4 k. {頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣7 j& c0 T- c- M! Y& h
瘜冽:
5 l$ y' \: l8 s4 h% F& F. U' J9 ^憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
) k+ l4 j% |# {& q# x' q; }鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:9 N- u+ p8 u. @3 S( g9 l
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
$ E7 l0 B! F/ }1 V& n! m. {' ymysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers1 z) i, Q& n/ x, T% I
:
9 |5 M* Y" I( w* F7 \) _決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:# I5 J( q" S+ j
vi /etc/my.cnf 乩:
; {4 X- Q! |$ k% M[mysqld]
7 r, q$ u: c7 E
% ]# j& U7 D3 n! C2 }7 [9 ]0 icharacter-set-server=utf8 q4 H0 I1 [6 r2 {
default_authentication_plugin=mysql_native_password
6 ]9 h/ } L2 P9 `% d8 O7 E' A% A) Y! h
[mysql]
1 b* q+ E) ~+ k) `9 ldefault-character-set=utf8
! o: O; q% s$ G
! e: Y; w( Y, T2 s* J- [- ^& d[client]) g3 F8 Z+ e# [: t+ E. P5 ?
default-character-set=utf8
' D9 | n! |2 s% Y
% ]1 o3 q+ m; E0 Y, H. t4 z嗅mysqld
# W+ b* v5 l, T" Lservice mysqld restart7 Q R6 y/ j6 o# f5 ~
摰!!
9 l# n3 Q+ o& p: v; l* l
0 o) _2 a; J% H, P
/ W P% |* Q& G |
|