酥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').
2 L: G: b; q3 p$ A6 p+ y+ [/ `
- S7 H6 I9 M- Y8 w" U( S臬歉hp 5.3隞亙撖蝣潭16雿蝺函Ⅳ,啁php 5.3隞亙41雿蝺函Ⅳ,mysql 5.2 隞亙閮凋16蝣,隞交甇斤車航炊.9 \7 R; O( ~* L: G3 `( F5 X
閮箸瑚銝mysql: (php 5.6.38 , mysql 5.1.73)
* l' ?, k$ c m5 J) \ z餃叮ysql 嗅頛詨 :
- n w$ z* l! umysql> SHOW VARIABLES LIKE 'old_passwords';2 C9 H) U& y! h5 Z( S
+------------------+-------+! G* J5 |1 N& e$ ?
| Variable_name | Value |
. ]9 x& s# x0 I8 [- X+------------------+-------+# |8 L! F% d2 t
| old_passwords | ON |4 \: T i2 I$ u$ D3 t S
+------------------+-------+! K1 s; U1 t/ ~) _% R6 B
1 row in set (0.00 sec)) w- {& q: W/ C+ g
3 r$ L6 X U5 \% e9 \
old_password ==> ON 撠梯”蝷 /etc/my.cnf 鋆 old_passwords=1 閮剖16蝣,撠摰閮剔 0 嗅mysqld ==> service mysqld restart
( `% U# |0 r: o4 x! f' \- T mysql prompt銝頛詨:) a+ z4 p" x0 E+ C+ N" g, J% [3 x: V
mysql> SET old_passwords=FALSE; & a8 V8 M+ E3 t( ^4 L/ M1 ~
瑼X叮ysql.user 瘥撖蝣潮瑕漲:
6 A0 t+ Z) p0 A% zmysql> SELECT 'User', 'Host', Length('Password') FROM mysql.user;
- d' Z1 `& D Y0 W# z/ O憒瘝寞41雿,Length('Password')甈雿閰脤賣160(銵函內瘝閮剖蝣) 2 {0 n/ `; _& ?. f, \
8 R! e7 H% r4 Q. b( n( @9 ]$ M |
閮剖靘撖蝣:/ b+ T2 `0 R! t
mysql> SET PASSWORD FOR 'root'@'192.168.1.1' = PASSWORD('靘撖蝣'); // 撠敹閬詨靘 撣唾@IP 湔,銝閬寥臭, ?8 Y, j3 z( Z: {' J
mysql> flush privileges;
% b9 _" K6 b% u& p) f M$ B5 p4 D0 \" T( O. g0 Q f
頛詨 SELECT 'User', 'Host', Length('Password') FROM mysql.user; 瑼X亙蝣澆漲,撠勗舐潛曉寧root 撖蝣潮瑕漲撌脫寧41蝣, d6 T3 a5 i' H1 _& }/ H) x* T) t9 ^, G
瘜冽:
& G& |" h7 m$ M7 B: u4 D憒撣唾憭芸,臭誑啣憿閮剖蝣,粹閮剖蝣 SET PASSWORD FOR 芷撠亙蝣,銝 old_passwords=0 撠撖蝣潮敶梢===========================================================================% d, h9 ?9 V& H2 `/ A
鄉ysql蝝 8.0.21,php逅ysql箇2銵errors:5 Q5 m3 E# P8 @; g7 Y4 r
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers; a/ ^0 f) d$ }7 m# T/ {- c
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers0 \ N2 E6 Q1 W/ O$ g6 B; f
:3 B, m$ {1 z6 j; Y$ T
決ySQL 8.0.21銝哨caching_sha2_password舫隤頨思遢撽霅隞塚銝臭誑敺mysql_native_password隞亙php銝詨捆臭誑蝝php嚗銋臭誑靽格遍ySQL蝵柴 曆犖瘙箏靽格遍ySQL蝵:
& p+ i I6 P. y; D4 n, ]; d3 ^vi /etc/my.cnf 乩:
& ^. [# f" B& ~9 R* ?[mysqld]
: {8 ] K0 w! V) H& J8 ?& {. q& e; V
character-set-server=utf8
; P: G& Y3 Y2 j [2 @' v* ^4 f7 Jdefault_authentication_plugin=mysql_native_password
- m1 F2 ^ F& S. r
) V4 q5 V8 o9 a3 k" r- }" s[mysql]( }) x! X8 N( e9 [/ Z" d
default-character-set=utf8
8 I! k: m5 \" D- A6 i/ s( c. D/ Q4 n0 F) i- \8 d `. U
[client]/ E3 Q! P; _9 C3 K# y# E
default-character-set=utf8
3 r# r s% |1 ]- M: P$ u
8 i) g, R. Z" T嗅mysqld
% J8 {5 z& l! P) t8 U& _% Uservice mysqld restart
/ V! b) \9 N; D4 B摰!! E& V! ^# l2 b
4 c3 j( T* N8 u# R' U8 z9 @
+ t. M& {) Y$ q |
|