码迷,mamicode.com
首页 > 数据库 > 详细

Windows下Mysql 5.7.10不能登陆的问题

时间:2016-01-22 13:37:37      阅读:1489      评论:0      收藏:0      [点我收藏+]

标签:

     安装完成后,无法登陆mysql,按理说新安装后默认是以root用户登陆,而且密码为空,所以可以直接进的,但是出现了下面的问题

     F:\mysql-5.7.10-win32\mysql-5.7.10-win32\bin>mysql -u root

     ERROR 1045(28000):Access denied for user ‘root‘@‘localhost‘(using password:NO)

     经过我上网查资料后发现新版MySQL默认有密码,之后我尝试在配置文件中加了skip-grant-tables,重启之后可以进去了;所以一定是密码的问题

     于是我又开始搜索各种解决办法,经过一番努力,终于找到了解决办法

     mysql>delete from mysql.user where user=‘root‘ and host=‘localhost‘;

     Query OK, 1 row affected(0.01 sec)

     mysql> select user,host from mysql.user;

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

     |user         |host       |

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

     |mysql.sys |localhost   |

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

     1 row in set(0.00 sec)

     mysql>flush privileges;

     Query OK,0 rows affected(0.00 sec)

     mysql>grant all on *.* to ‘root‘@‘localhost‘ identified by ‘dingwei351‘;

     Query OK,0 rows affected, 1 warning(0.00 sec)

     mysql>select user,host from mysql.user;

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

     |user        |host         |

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

     |mysql.sys |localhost  |

     |root        |localhost  |

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

      2 rows in set(0.01 sec)

     但是到这还是不行,你用下面的命令会发现一个情况

     mysql>select * from mysql.user;

     Grant显示N--mysql权限架构体系(应该是这么说)是关闭的,所以应该执行下面的操作

     mysql>grant all on *.* to ‘root‘@‘localhost‘ identified by ‘dingwei351‘ with grant option;

     Query OK,0 rows affected(0.01 sec)

     退出mysql,将skip-grant-tables注掉,然后重启mysql。此时再登陆就可以了。

      F:\mysql-5.7.10-win32\mysql-5.7.10-win32\bin>mysql -u root -p

      Enter password:**********

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

      Your MySQL connection id is 2

      Server version:5.7.10  MySQL Community Server<GPL>

      Copyright<c>2000,2015,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.

 

    

 

Windows下Mysql 5.7.10不能登陆的问题

标签:

原文地址:http://www.cnblogs.com/fighting-ayong/p/5150486.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!