mysql localhost 拒绝_MySQL错误:用户’a’@’localhost’拒绝访问(使用密码:YES)

我使用root帐户创建帐户’a’@’%’.但是当我指定host参数时,我无法使用该帐户连接到

MySQL服务器.我可以在没有-h参数的情况下成功连接.请参阅下面的成绩单.我希望有人可以帮我解释一下.谢谢.

mysql> grant all on *.* to 'a'@'%' identified by a;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a' at line 1

mysql> grant all on *.* to 'a'@'%' identified by 'a';

Query OK, 0 rows affected (0.00 sec)

mysql> show grants for 'a'@'%';

+-----------------------------------------------------------------------------------------------------------+

| Grants for a@% |

+-----------------------------------------------------------------------------------------------------------+

| GRANT ALL PRIVILEGES ON *.* TO 'a'@'%' IDENTIFIED BY PASSWORD '*667F407DE7C6AD07358FA38DAED7828A72014B4E' |

+-----------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

mysql> exit

Bye

[root@localhost ~]# mysql -h localhost -u a -p

Enter password:

ERROR 1045 (28000): Access denied for user 'a'@'localhost' (using password: YES)

[root@localhost ~]# mysql -h 127.0.0.1 -u a -p

Enter password:

ERROR 1045 (28000): Access denied for user 'a'@'localhost' (using password: YES)

[root@localhost ~]# mysql -u a -p

Enter password:

ERROR 1045 (28000): Access denied for user 'a'@'localhost' (using password: YES)

[root@localhost ~]# mysql -u a

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 20

Server version: 5.5.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

mysql> status

--------------

mysql Ver 14.14 Distrib 5.5.17, for Linux (x86_64) using readline 5.1

Connection id: 20

Current database:

Current user: a@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter: ;

Server version: 5.5.17 MySQL Community Server (GPL)

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db characterset: utf8

Client characterset: utf8

Conn. characterset: utf8

UNIX socket: /var/lib/mysql/mysql.sock

Uptime: 15 days 15 hours 20 min 18 sec

Threads: 1 Questions: 40 Slow queries: 0 Opens: 41 Flush tables: 1 Open tables: 4 Queries per second avg: 0.000

--------------

mysql>

编辑:

是的,MySQL正在侦听端口3306.

[root@localhost ~]# nmap localhost

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-01-18 07:35 CST

Interesting ports on localhost.localdomain (127.0.0.1):

Not shown: 1674 closed ports

PORT STATE SERVICE

22/tcp open ssh

25/tcp open smtp

111/tcp open rpcbind

631/tcp open ipp

840/tcp open unknown

3306/tcp open mysql

Nmap finished: 1 IP address (1 host up) scanned in 0.064 seconds

[root@localhost ~]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值