解决mysql不用用户名和密码可以直接登陆的问题

来源:互联网 发布:mac系统忘记密码 编辑:程序博客网 时间:2024/05/19 17:05

转载自:解决mysql不用用户名和密码可以直接登陆的问题

作者声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://linzm.blog.51cto.com/1854885/1275701

原作者:teleyic


红色部分为我添加的内容

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,有空用户名的记录

先用root账户登录,然后用 

use 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)


0 0
原创粉丝点击