找回密码
 注册
查看: 3285|回复: 2

mysql直接不用用户和密码登陆解决办法

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2020-5-7 17:00:00 | 显示全部楼层 |阅读模式
mysql> select Host,User from user;
% }' E/ s: d/ ?* T# D( W4 m+ p+ I+-------------------+------------+
- ^' n2 J# n* X4 K, y| Host              | User       |
/ P5 P) \( t" i+-------------------+------------+
1 r0 n$ R1 Q. l; d& u8 Y; J1 ~| 127.0.0.1         | root       |+ T8 z. B! Z9 l0 U# J$ s* B% e3 b
: s# t; x. N: O  e* D
! y) Y6 m& {! ]  U
| ::1               | root       |/ O; u; R  A7 K2 _( X& c0 V
| localhost         |            |# g* R: n$ ~3 R: M- \, {
| localhost         | root       |/ B0 Q) {. n# h% X; `( A; L) ?

9 a4 w; q' |( R" N% n1 \) I+ `& G: |, Q+ n+ \4 b
| localhost.example |            |- l1 E. [% p4 ]" o% O5 ~
| localhost.example | root       |
! p- ~; D8 U; ]  N0 t+-------------------+------------+
$ [4 S* ^% B+ x: [+ @6 @12 rows in set (0.00 sec)) s* M0 ^0 n( O) \  e
mysql> delete from user where Host='::1';* |7 D' V: ^4 A- h; P8 C$ N/ ?
Query OK, 1 row affected (0.00 sec)2 J5 L0 ]6 S7 M9 |! U$ G! h
mysql> flush privileges;1 p& r( t: r6 h7 T$ V
Query OK, 0 rows affected (0.00 sec)" O/ @, d5 n/ I% `& L. Z3 {/ m) E

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2020-5-7 17:00:01 | 显示全部楼层
mysql> use mysql& h  u. ]2 }- u' n0 z4 ?
Reading table information for completion of table and column names
# t5 U' o- N# B4 @, h) tYou can turn off this feature to get a quicker startup with -A
, `- R2 L! ?( w0 gDatabase changed! Y1 G' b) @7 t* f3 P# k
mysql> select Host,User from user;
$ ^; U% N; \: b# N+-------------------+------------+2 O9 z3 o/ m/ [- [  i
| Host              | User       |
$ q$ z  M/ T  a, E% B+-------------------+------------+
9 Y# G: y4 z7 Y2 X) E) C7 f| 127.0.0.1         | root       |$ K  N" z3 m4 S/ O# I" S, L
| localhost         |            |( r! o8 I; q3 k7 q
| localhost         | root       |
2 p+ ~9 ]0 u9 ^6 s0 l+ e# |, u| localhost.example |            |
0 f: ?& b' T" E( w6 }/ o* d* D( || localhost.example | root       |
$ L7 u) ?* U2 v$ u/ j+-------------------+------------++ {5 p$ F% z7 @, `$ @1 G
11 rows in set (0.00 sec)
" X( k2 t& Z6 }4 umysql> delete from user where Host='localhost.example';$ O! G4 B5 _. Q
Query OK, 2 rows affected (0.00 sec)1 W, \3 n  o$ s) z" L
mysql> select Host,User from user;
0 x: P' |, c! g+ @& e3 a  F+--------------+------------+
, A! M/ L# F  g1 o  F$ `' e| Host         | User       |: d6 d8 Q" z1 f# E% M2 \
+--------------+------------+
3 ^: `. g! t- a) B8 K| 127.0.0.1    | root       |! A8 D' R5 a. M# ]
| localhost    |            |, _' G8 [7 \, ^# j2 p
| localhost    | root       |3 i  Q, w. q8 P4 I+ U( p
+--------------+------------+
) i, x8 E. s# Z# ]9 rows in set (0.00 sec)7 x6 p' t" W8 M  d* \' S
mysql> delete from user where User='' ;
* t& |% G1 W; X3 s2 _Query OK, 1 row affected (0.00 sec)
2 O! A0 V$ H# Q1 m+ s/ E$ \mysql> select Host,User from user;- j5 h- N; {* q! }; E$ u8 }5 p
+--------------+------------+/ T  r- A  W! R4 W  R2 U; f6 e
| Host         | User       |# r. R8 ^' C. ]* S6 R* p) P% I
+--------------+------------+
& P" E" j# @" \7 a, G- Z| 127.0.0.1    | root       |( l4 q6 o* j0 e" x* [8 z* q; ]3 \/ y
| localhost    | root       |
1 x3 @+ y4 ?3 b) d! m+--------------+------------+# Z2 }4 N! j& T- Y/ E1 N
8 rows in set (0.00 sec)
' c1 y$ s) S6 q

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2020-5-7 17:00:02 | 显示全部楼层
mysql> select count(*) from user where user='';6 }) o) j) I! G; k# t' m0 ~
+----------+/ M! z: ~) L- l4 e3 V1 H
| count(*) |
  c* @1 c+ v% a, X% Z+----------+
8 I+ f( m- ?6 Y& Q  _|        0 |
$ _! P5 i' j0 a6 P" k+----------+
1 S5 }5 O$ Z* s) @! U& Z( Q1 row in set (0.00 sec)( Q" z6 k9 I4 h

' \  V& Z& Z  N7 y; lmysql> delete from user
# W  h- S1 f* \) ^user                        user.Create_view_priv       user.Insert_priv            user.Process_priv           user.ssl_cipher            
# E. P. A# _& l4 J' ouser.Alter_priv             user.Delete_priv            user.Lock_tables_priv       user.References_priv        user.ssl_type              
! K9 l  f, u" q2 b9 Zuser.Alter_routine_priv     user.Drop_priv              user.max_connections        user.Reload_priv            user.Super_priv            0 F* S) }. u- j/ B9 ]' a
user.authentication_string  user.Event_priv             user.max_questions          user.Repl_client_priv       user.Trigger_priv         
6 p% k# _& v/ s" zuser.Create_priv            user.Execute_priv           user.max_updates            user.Repl_slave_priv        user.Update_priv           ' u1 {9 @0 q" X
user.Create_routine_priv    user.File_priv              user.max_user_connections   user.Select_priv            user.User                  
, H5 K+ K8 @' W+ v* A$ u) quser.Create_tablespace_priv user.Grant_priv             user.Password               user.Show_db_priv           user.x509_issuer           8 K# w* S7 @2 S( @+ ^0 E
user.Create_tmp_table_priv  user.Host                   user.password_expired       user.Show_view_priv         user.x509_subject         
& R/ A4 z' Q/ F9 Y; N. nuser.Create_user_priv       user.Index_priv             user.plugin                 user.Shutdown_priv          user_host                  
& O6 A: S& p. x9 b0 Nmysql> delete from user where user='';$ b* O3 v0 l* o
Query OK, 0 rows affected (0.00 sec); p% Z9 t4 G  o5 u* w& ?1 m, C
' X* p3 M& ~& p( r- x1 ~, A! x+ V
mysql> flush privileges;
, J: e. C* J* C- J  _: }Query OK, 0 rows affected (0.00 sec)7 P4 q) l2 S" E+ H! r) v: L) f

# j' _; z: z( _3 V2 f. Pmysql> ) A4 c" b6 L% ^. a0 P/ s- z; O" e! t
. o" e; a9 Q1 m) ?1 H9 y
[www@webbs168x ~]$ mysql
. T: w5 s: ^9 b, _ERROR 1045 (28000): Access denied for user 'www'@'localhost' (using password: NO)# b3 a: t* m& ^/ `5 B" v, M8 W
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 02:21 , Processed in 0.021236 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表