酥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 q3 {3 { n6 b% \. d
# ]+ A F3 Y* c' T: x臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
9 c4 d5 z; W7 M+ X5 Y) s. x3 j1 b閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)# O/ B+ L+ M2 P) y% _7 D4 [
餃叮ysql 嗅頛詨 :
( {$ ?) x P+ |; s, n4 Z" zmysql> SHOW VARIABLES LIKE 'old_passwords';
% g) A* M ]+ z: z3 q+------------------+-------+0 Q/ I" j+ I& d! q. ]9 v0 @
| Variable_name | Value |2 j4 k5 S4 [9 b+ z/ q: r; w9 g1 h
+------------------+-------+3 p+ Z1 I- [+ }" ~
| old_passwords | ON |; l9 T% q S! ^. O/ r" z9 d7 Z
+------------------+-------+
5 \/ Y- z# ~/ A; C1 row in set (0.00 sec)
5 a8 L1 m5 _+ f g$ h; Z
$ j4 I# \9 e- E, F& G( yold_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart2 Y) ]) O( R7 E( ~
mysql prompt銝頛詨:
' S. e% {, O8 v" P4 E: }mysql> SET old_passwords=FALSE;
: [* `. X, ~4 k( k5 J* s5 G瑼X叮ysql.user 瘥撖蝣潮瑕漲:
& O4 C+ t8 b! L' R8 U0 _+ Ymysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
, j# k9 A! A( v: \ s憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣)
* C+ `/ @( Z; F: N C- a9 f
# O# o2 @. @8 {1 w3 W* O閮剖靘撖蝣:$ v* G; Z' A/ ]0 @- o
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭/ B1 m9 t+ f5 Q0 ~5 i0 w- m
mysql> flush privileges;
4 i8 j: @* W- o n+ I* @
y/ k3 `! @: m `/ `+ m7 |頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
/ v7 Y# b6 h5 T% T$ ]瘜冽:
: X- C! l( q4 l( m0 l憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================* w9 q' B! M, y+ @2 H& s( W0 J
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:
3 j3 r4 |7 T4 K( f' I7 A P$ ^! Kmysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
! g! l1 ]: D) z, {+ ?mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers0 J: ]3 \' W2 V4 I0 Q: M1 b
:7 p: I* m. P. ]9 F
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
% ~6 |3 y, d$ p$ yvi /etc/my.cnf 乩:
, q7 P2 V' V" x5 m, q/ B6 E[mysqld]
5 R, d1 w2 Y* h8 Z9 B4 S: b4 F$ ]% l, e% ` Y
character-set-server=utf84 k- R4 _, B# @6 ^# `9 B& D
default_authentication_plugin=mysql_native_password
1 @. U5 t1 o2 G6 n( s* n5 y/ Z! S/ G! U: V9 \
[mysql]
$ E' i8 G; n. ^9 t. ~default-character-set=utf8; b7 z' N2 e% c% p
6 ^8 _/ b* L3 ]6 q" g+ M4 y[client]
9 `: ?8 C! R9 L0 ~default-character-set=utf8
+ g! k& e+ |" g: K4 ?& m' w& I. Z/ p M/ j
嗅mysqld$ b+ s$ S0 m5 U3 T
service mysqld restart
% n% }! K4 r0 b0 N摰!!
" i0 e: o1 I9 W0 B# H. x
* G0 a1 m1 E1 Z9 f Y! F
0 z. P! Y: S. @' c G |
|