酥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 \" a3 ]& w. k8 p# i
6 K. u- d# K" J6 @& V( [臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.
8 v) O$ L! h! g [閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)4 f. x. n) A. B T0 l
餃叮ysql 嗅頛詨 :
% Y! \' W7 ~- k/ Omysql> SHOW VARIABLES LIKE 'old_passwords';
4 V5 \( y! Y t/ u+------------------+-------+
: x5 n( ^; x( M+ s" }| Variable_name | Value |4 n* {# t: Q# J7 L9 t
+------------------+-------+
3 w; X( a* i+ | @) ? G% R| old_passwords | ON |
: i9 D9 S: q. M+------------------+-------+
4 O) k' f, \, ]) t& o1 row in set (0.00 sec)
6 m& J) |# f9 J7 n7 ]$ X; x; S* E* d5 S6 ]/ e: `) i" K
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart. f7 s4 Y1 e3 F) Y5 k0 o
mysql prompt銝頛詨:
! j; ?- {3 A* J! L: o' r6 tmysql> SET old_passwords=FALSE; & h- \# Z" u- k
瑼X叮ysql.user 瘥撖蝣潮瑕漲:$ t X# _5 o1 a
mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
7 [. T3 b+ k# u3 k6 ~/ A憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) T/ L. g1 H0 B& p! s
+ }4 Y* D0 q% M
閮剖靘撖蝣:) a) q& ^* \! ^# Z
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭
: G8 g3 _. ]+ z6 ^) D, k$ f/ i3 Amysql> flush privileges;$ q. O; D, d- q% I" L* s) |0 I- ~
- A2 Y$ n% P$ h, C. H% P- i9 l頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
* W' o& M* |( _% l. A1 U瘜冽:# a: {5 w1 W2 w1 K
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================; P( B5 A( ~5 @" z
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:- ^) J& u6 M. y- o+ P5 D
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers. l/ F7 }0 R" l, g9 s: Z$ o
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
T& D0 C% f* q6 q" o6 V:
/ T% w; L( Y4 t u8 l決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
( t2 X, D4 r) v2 tvi /etc/my.cnf 乩:
( |+ b& s8 m" y9 l: D$ Q3 N[mysqld]) O! z0 a7 [! A+ l& G. F. y
8 J9 Z0 j) [. i/ R. I( v
character-set-server=utf85 { h3 B* X0 \2 D. @
default_authentication_plugin=mysql_native_password( B6 M0 P& _0 ^1 l V* D# J# K: u
, @/ R" A+ G9 @. Y
[mysql]
6 u/ v2 J! L2 f1 P5 }. Q0 Rdefault-character-set=utf82 u ~# _1 L' M$ m+ Z7 E1 v
) l# y6 X1 `; Z* \' K( j* l: M# P
[client]
( Q! Q+ `0 t2 Ddefault-character-set=utf8( }! ^+ P7 W( ^+ Z; D
) C; q! ~5 d9 G嗅mysqld
9 u$ e) ~( y( B* o6 G, Mservice mysqld restart
7 h' C; a' [( [2 H/ w7 T) A: c1 ~摰!!) S/ O. c2 N5 K- j* Z- `
1 J; G+ B+ r9 h4 _1 n3 {
- B# ?) c3 B" d5 u- t: z7 t |
|