酥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'). r+ I& m1 m, ?5 m
, N% E( h" J) @ D- ?% e. g- e3 u
臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.; m0 e+ Z! K3 |2 G! f7 k
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
6 } E9 o) O( K% y餃叮ysql 嗅頛詨 : 6 {9 p0 R H( i) h+ X* y
mysql> SHOW VARIABLES LIKE 'old_passwords';/ U9 S5 x! m, x) t5 N4 C0 s" t
+------------------+-------+
" ~6 O6 W7 R9 b8 Q$ F| Variable_name | Value |
$ W* w" @4 W" R6 O! u3 T' O+------------------+-------+
/ d. j/ e) p) b2 A/ s8 u7 i| old_passwords | ON |# c5 L/ {- P& a2 w" ?' V
+------------------+-------+- }3 L2 W: I, e; Q5 m4 Q# j) s
1 row in set (0.00 sec)
* {! V% M% r0 C! G( G9 V* X* O+ x1 |4 E {- X8 [
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart5 n9 @. b2 ~; v# G1 n$ Y
mysql prompt銝頛詨:6 I& k6 Z3 D% @4 t* P, \
mysql> SET old_passwords=FALSE; 1 M* C+ [3 B" p) D
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
+ c8 R4 w8 l, S. g! T$ ]mysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;- J3 i% F# M) Z3 k4 T
憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) 3 N" p$ m0 n$ ~# Z
6 S8 f" W! u/ b+ u! A. n' c* Q, Y9 ]閮剖靘撖蝣:
- F; h5 S- t# t2 F- xmysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭 Y: V: X; W+ p3 r$ F% K
mysql> flush privileges;
+ e; |5 i& S+ L& q: i% J
! Q6 |' R& ]+ E3 K" U8 R3 ^) G6 O頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣
& V& m1 ]3 D$ S% [1 `; z瘜冽:6 q$ d4 Q! {" b( d7 j
憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================
; B' x9 c" C3 m5 Q: y$ l8 T鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:7 G& w' S2 t& Q2 y+ {7 N) z
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
& R: O, _& K/ A( rmysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers4 c' [5 j6 m4 D4 W$ }: y2 v) J4 H
:, t+ e4 q+ }2 B/ Z6 a% W
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
1 \# W, H/ z* D5 I/ _" g8 y& Gvi /etc/my.cnf 乩:, W4 w: _% [; k2 s. M& H
[mysqld]
* m/ W9 r6 x8 y. ?; ?7 @ ]; f9 u/ c, e6 ~" _- k, d
character-set-server=utf89 n9 B9 z+ r. q' h) Q0 a( L
default_authentication_plugin=mysql_native_password$ R8 H5 V4 K1 g
" n- J* s4 h$ t: |% N[mysql]) v* K1 b+ J( x' s5 F- |
default-character-set=utf84 ]4 N }. ? S2 e Y- q
( N' K5 _# ^ c% h( S
[client]
) l, i1 ^3 u- `4 p0 u Wdefault-character-set=utf8
0 g& q( i& d( A1 A3 ^- v+ U
$ W4 E5 g# s( f& r嗅mysqld$ L$ B5 v' X$ \) l; Q5 m
service mysqld restart& O7 [% c6 |$ q6 ]
摰!!
i9 b, x4 ]0 t" J3 Y- [! T$ n# K0 ~8 j3 q* G) F1 s& t* m" U" h0 c
4 G8 s) F7 j; | J8 M |
|