酥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').9 ?; x* c8 i `6 p$ D/ ?. m
8 A8 |5 N* r- i; S0 b
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
( V9 h% T3 R$ x" F4 i4 Y閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
1 m1 G7 \& ^% n餃叮ysql 嗅頛詨 : 3 K8 v, l" z+ B9 A" j
mysql> SHOW VARIABLES LIKE 'old_passwords';
/ g! `* c) w7 _+ V' d" n+------------------+-------+
9 X: f0 j: X% L" J) }& w$ m| Variable_name | Value |5 D6 o. p9 f2 w4 ^3 }; j1 F! J
+------------------+-------+; ^5 v) q$ L- m/ }8 [/ H
| old_passwords | ON |2 @3 h. b- E: C0 L) h
+------------------+-------+$ y( H# a" {. A- N7 Z; k+ ?$ q
1 row in set (0.00 sec)
; |, i7 D5 T# { U* y% T; H C+ I, g' U& F
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart0 w/ N+ Q3 V5 K
mysql prompt銝頛詨:
7 E& s9 D( A* |3 F. q, \' p9 B( Lmysql> SET old_passwords=FALSE; ; U( l! U) P6 E* ]! Y1 R
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
. r9 L% R+ t& U( J2 Z5 `0 mmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
/ ~# e1 q" T4 [( c1 w2 ~憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
! |8 [7 a1 N, n9 T) Q L4 T% \( C% }2 X5 P1 q) F1 j1 c, P
閮剖靘撖蝣:
+ h# t5 i4 ~' L9 F, x4 I% imysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
$ P5 q( H1 X6 Z# y( K- Xmysql> flush privileges;
! h4 M) Z8 i) s. e# T
* O6 a3 G O5 K+ a. o5 v# H2 }$ Q頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
8 q( Z. k9 k! Q4 V& D* G% A6 I# m瘜冽: Y& V) h, D* g* g: P9 f7 k
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
! w! H1 Z" v4 n鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:7 l8 M5 R2 @( j( V6 r
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers8 _0 ]7 Y/ K) k7 h
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
7 \& O/ q; ^8 z$ V$ i: v5 G/ W:+ K4 ~ L! H# d$ H) E) {
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:* o- J& R$ D' G
vi /etc/my.cnf 乩:
* N3 t' a/ _" F, C( R* Z# y- T4 M[mysqld]2 \ U" j; k/ W9 X( {6 a
4 N2 y& p2 K: A- ?* Y, W- q' tcharacter-set-server=utf88 Z6 M; l) ], I0 C | M$ c1 @" u
default_authentication_plugin=mysql_native_password
3 U/ {) a- [' v, d- V X6 ` |
$ I+ I8 e- E! m4 a% D1 W[mysql]8 Y0 a: b! r! \8 ]% j6 m6 N
default-character-set=utf8
$ _9 F/ k! k$ x, n$ V; h
% y0 [7 i8 o% d$ \% n[client]
5 @) n% M' _. t: o$ Y& b7 x% gdefault-character-set=utf8
7 Y0 e- A: E. _, c
+ [. f* X# _; w; G嗅mysqld* z9 r" S3 Z9 }7 C9 z$ b5 f
service mysqld restart& V4 d" ~+ c4 Q; d. r# @2 |
摰!!6 V$ h0 v2 j A7 F; K
3 z) N1 M# ?7 e: k# [% |" ]
, o5 `- z7 G2 ]8 ^+ s3 A* g
|
|