易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 3282|回复: 2
收起左侧

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

[复制链接]
发表于 2020-5-7 17:00:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
mysql> select Host,User from user;
1 S! W7 u8 D6 w0 L' H& ?! S+-------------------+------------++ B* T" U( w( j$ j1 s7 u. E
| Host              | User       |
0 o' F7 w/ D) V1 g$ v* I7 r+-------------------+------------+& l$ c& V3 V* P6 l
| 127.0.0.1         | root       |
) g8 C# ]3 O3 R: X$ ]3 O/ N  d( r
, ~8 ~( e, w( m; n( d
- j) _% z! r$ _| ::1               | root       |% C% h0 b0 E  f0 q) n7 Q# S
| localhost         |            |$ U* t) b( j" _& e
| localhost         | root       |! z* ?6 j% H, l( L4 B- C
" e  A, ^  o4 o0 a( [

' R! b$ J( K4 n/ @1 u| localhost.example |            |
* N% w) H; z9 t* K% V| localhost.example | root       |
- B" S4 p, h4 d! i0 }7 |1 B! S: ?/ H+-------------------+------------+2 g8 I- _/ I9 S4 [4 I
12 rows in set (0.00 sec)
8 N0 J. T9 Y% s5 Fmysql> delete from user where Host='::1';
8 J8 u! J$ g2 J! _4 I# }! f; wQuery OK, 1 row affected (0.00 sec)
5 j" b: A. h* ]1 [6 }1 p, V8 Rmysql> flush privileges;
4 M! g! |, g& {* V" y/ U; N  {Query OK, 0 rows affected (0.00 sec)7 l" C9 F; K0 d0 r* l. u8 K+ z
 楼主| 发表于 2020-5-7 17:00:01 | 显示全部楼层
mysql> use mysql! d; v; c* g# a6 ~
Reading table information for completion of table and column names- u& [6 g- d5 u, |* c
You can turn off this feature to get a quicker startup with -A8 i. G/ j& q! R+ D9 d& z4 C) o# @
Database changed
  N4 q* R; n+ S5 Wmysql> select Host,User from user;
& j6 `: z6 C3 ~9 {# e+-------------------+------------+" y( g6 Z  y* m2 U5 x. g  I
| Host              | User       |) e/ G; k! o3 @. c* L, Y* K5 z8 `: ]
+-------------------+------------+
: E7 Z, F& X+ s# W: J; J| 127.0.0.1         | root       |3 }& O! e# R) f( F+ g
| localhost         |            |) j) a8 j1 d; `: \) @$ d
| localhost         | root       |
2 @0 }  m: x! K# {| localhost.example |            |  K9 B  L# R$ W% N: [2 H& ^/ Y
| localhost.example | root       |  n: C+ ]7 w( J0 U& k) m
+-------------------+------------+
9 L* j% d( I  B7 \! x; q! Q4 i11 rows in set (0.00 sec)2 D5 L% R0 x' ]. h8 D
mysql> delete from user where Host='localhost.example';
5 Q( J& x6 |1 o) F3 oQuery OK, 2 rows affected (0.00 sec)- Q1 {! }) c9 J8 e- w
mysql> select Host,User from user;
) T4 [: Q; g. G+--------------+------------+/ e  J: i0 u0 }* ^- {! y
| Host         | User       |
7 U5 n" w$ d- V0 t* `1 D$ n+--------------+------------+
/ x+ W2 y! z6 A4 A| 127.0.0.1    | root       |( {2 F" O" |2 r% E
| localhost    |            |  F; K) Y; ]: w0 h! v+ ]0 q
| localhost    | root       |
$ U! O7 s# A: l" ]3 @: n* S* f8 V+--------------+------------+5 x; j" O" M% _5 c2 Q6 w; {
9 rows in set (0.00 sec). i& j. u& @9 M+ T" y. t" U
mysql> delete from user where User='' ;( K6 E' B$ m- {. p$ I
Query OK, 1 row affected (0.00 sec)
0 w  G+ D. n! s6 C. Amysql> select Host,User from user;
* P( a8 ?# a$ O$ e  \/ _+--------------+------------+4 H% T" Z, A4 O  s* a3 l' s9 q. \
| Host         | User       |1 Z1 g& s4 j/ X9 q9 z
+--------------+------------+
" R  m( @& x# B| 127.0.0.1    | root       |" ?5 e  c+ `9 m9 F+ H
| localhost    | root       |
6 `+ F' _0 p: `! Q% T+--------------+------------+
: D2 z6 g4 u3 V" j* G8 rows in set (0.00 sec)
+ t' N5 O1 C% j! |
 楼主| 发表于 2020-5-7 17:00:02 | 显示全部楼层
mysql> select count(*) from user where user='';
0 J0 T7 A, p# i1 d( \4 e+----------+, G) A* s& M/ q( L2 F2 s
| count(*) |
3 X: p; W$ E9 G  s+----------+
% o; `5 g& F/ a/ J( _0 l7 p. W|        0 |7 ]: P* V0 T; [4 y
+----------+( k* K0 u, q  y" g; g) [2 i$ Y! ?
1 row in set (0.00 sec)
, ^  R3 B' T3 }$ L9 p+ i0 L+ C
# B8 t" e5 ?/ r5 ^: ~mysql> delete from user
  W4 R$ b) ~+ [/ `user                        user.Create_view_priv       user.Insert_priv            user.Process_priv           user.ssl_cipher            
) n: M: H$ r+ fuser.Alter_priv             user.Delete_priv            user.Lock_tables_priv       user.References_priv        user.ssl_type                w; |3 @9 y. n) }% |/ s# U& z
user.Alter_routine_priv     user.Drop_priv              user.max_connections        user.Reload_priv            user.Super_priv            ; d4 }3 ]& d/ h; Y4 k8 \
user.authentication_string  user.Event_priv             user.max_questions          user.Repl_client_priv       user.Trigger_priv          3 [2 G" K9 Z: H( X) ]
user.Create_priv            user.Execute_priv           user.max_updates            user.Repl_slave_priv        user.Update_priv           ; ^$ I% q& d2 \/ Y; i2 l( W
user.Create_routine_priv    user.File_priv              user.max_user_connections   user.Select_priv            user.User                  
1 |  f6 b) k3 Z9 D, Muser.Create_tablespace_priv user.Grant_priv             user.Password               user.Show_db_priv           user.x509_issuer           
6 T6 Y6 l6 n% f3 U5 b. |$ Xuser.Create_tmp_table_priv  user.Host                   user.password_expired       user.Show_view_priv         user.x509_subject         
- r9 e# |8 o- Y+ I$ |3 q2 i: K4 P; t2 Juser.Create_user_priv       user.Index_priv             user.plugin                 user.Shutdown_priv          user_host                  # s3 o! x, g$ ^) x& \
mysql> delete from user where user='';
( d% `6 e1 W" Z! d' Y# P) b/ {# q6 tQuery OK, 0 rows affected (0.00 sec)
! w0 T2 I- L& l* |4 f' I7 a
9 K, {* I1 Q  ]# e/ ]2 s0 Zmysql> flush privileges;
: f0 z& H. T+ i. RQuery OK, 0 rows affected (0.00 sec)
# w7 T# x' D8 z8 [; w: I" j1 W4 w
7 s" x; v" X2 x& emysql>
  a2 |% ?3 L  o1 h
4 \' I) W& ^( ?% }6 F' O8 y7 m[www@webbs168x ~]$ mysql 9 [3 L) e  Z- N, E4 h
ERROR 1045 (28000): Access denied for user 'www'@'localhost' (using password: NO)
: @5 T; C1 T/ T, \+ a, y* t
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 13:47 , Processed in 0.039616 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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