酥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# V5 z% Y+ g0 s
( l" }# G0 C' C+ @( h
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
$ V% J$ N) ?) q+ H6 T) x閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
, C: A7 l$ k, P+ V餃叮ysql 嗅頛詨 :
6 \ a6 c; X1 {5 O6 o7 k4 `mysql> SHOW VARIABLES LIKE 'old_passwords';( l/ P/ K9 P2 d/ r
+------------------+-------+; z, D6 ]' b% }. G2 \$ S
| Variable_name | Value |
6 h* {' y- o$ c# ?+------------------+-------+# ~" M+ a: K& g: x% B
| old_passwords | ON |2 |3 Q; D; z% K9 d9 n
+------------------+-------+
& Z/ N# i9 w5 U$ Y1 row in set (0.00 sec)
: }. M# S9 ^# d
; x- b% a7 [: {! h9 B7 u5 vold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart& K& j" V! ^' W% I
mysql prompt銝頛詨:
0 E3 m& D7 V5 n7 n% zmysql> SET old_passwords=FALSE; 4 W! M. I. B. E) B% I! b
瑼X叮ysql.user 瘥撖蝣潮瑕漲:! t0 {+ N5 Y. h! u5 Q
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user; d6 E3 b- X) H! |+ R% ]
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) $ Y6 f- Y% M" T9 H( C% O$ B9 v
4 }) u/ i' ^; E U: h! x, e8 g閮剖靘撖蝣:
# [2 i- N" d2 h& Z+ m3 jmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
1 x, n6 S. u4 ^/ @) G( z( tmysql> flush privileges;
" _! k( u* Q i1 {4 w9 v8 g. \, r$ q5 e0 j6 U
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣- ~' w" c5 [& ?% o4 w9 A
瘜冽:* ~7 j, f8 I- b( {5 K
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
$ l# x& G- ~& q" x鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:8 `5 H$ b2 P, @2 q p; s
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
Z1 h3 ?2 T( C3 |5 g4 z# y- ]mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers8 G- @$ ^; j" V2 L
:
; `1 j* M# E: Q# P決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
9 r1 Y+ Q" e# _% cvi /etc/my.cnf 乩:
: A7 k# Y5 P) h- } J! w[mysqld]; U* f1 z" M8 a- l- ?& V0 C" x
* } V2 o* u5 V6 v8 R; bcharacter-set-server=utf8) I" O C/ f/ \, A% \
default_authentication_plugin=mysql_native_password
3 `. _$ ` k6 m; C0 c- r; w4 J2 B/ e+ W! g; Z ^, ~7 X: g
[mysql]! c4 k) m. ~: X2 y+ X5 U% x
default-character-set=utf8
: j' m& l* e0 d. A' y
) o' r; B# ~$ R3 d[client]
$ b/ w; f6 z% m" R, _6 n6 tdefault-character-set=utf8
5 h5 j* l; {6 ~6 ~5 h9 _' y% K. \/ A- a, P- H# Z9 n6 O
嗅mysqld2 F/ J( L5 b- v. h; p
service mysqld restart( }) V/ w9 }9 {. ]' }
摰!!( w# a' f4 n) e c& Y
4 n! ~' R d4 w( ^- [
2 V6 A. x! ~! T |
|