1、默认情况下,mysql不需要输入用户名和密码,就可以登录

C:\Users\linzm>mysql

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

Your MySQL connection id is 1

Server version: 5.5.32-log MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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.


2、因为默认安装的mysql,有空用户名的记录

mysql> select count(*) from user where user='';

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

| count(*) |

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

|        1 |

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

1 row in set (0.00 sec)


3、为了安全考虑,需要删除这个功能,可以登录进去mysql,删除掉

mysql>use mysql;

mysql>delete from user where user='';

mysql>flush privileges; (必须的)


4、检查修改的结果:这时候,再次用mysql空用户名登录,报错

C:\Users\linzm>mysql

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)