zoukankan      html  css  js  c++  java
  • MySQL登陆小问题

    root用户创建用户

    CREATE USER gechong
    IDENTIFIED BY 'gechong';

    登录数据库时提示错误:

    C:Usersgechong>mysql -u gechong -p
    Enter password: *******
    ERROR 1045 (28000): Access denied for user 'gechong'@'localhost' (using password: YES)

     



    另外一种方式创建用户

    CREATE USER gechong@localhost
    IDENTIFIED BY 'gechong';

    登录数据库

     

    C:Usersgechong>mysql -u gechong -p
    Enter password: *******
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 106
    Server version: 5.6.13 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.
    
    mysql>

    查找原因: 

    查看mysql.user

    第一种方式创建的用户:

    SELECT Host,User,Password
    FROM user
    WHERE user='gechong';
    
    +------+---------+-------------------------------------------+
    | Host | User    | Password                                  |
    +------+---------+-------------------------------------------+
    | %    | gechong | *11B9ACA21786F766739D0EB1483C5F64212B81AC |
    +------+---------+-------------------------------------------+

     

     

    第二种方式创建的用户:

    SELECT Host,User,Password
    FROM user
    WHERE user='gechong';
    
    +-----------+---------+-------------------------------------------+
    | Host      | User    | Password                                  |
    +-----------+---------+-------------------------------------------+
    | localhost | gechong | *11B9ACA21786F766739D0EB1483C5F64212B81AC |
    +-----------+---------+-------------------------------------------+

     

    原因找到了,原来是user表中没有相应的localhost字段

    总结:在创建或者删除用户时,如果创建语句能在Host字段中添加内容,则在创建或者删除时必须加上@"该内容"(%除外)。

  • 相关阅读:
    [HAOI2008]下落的圆盘
    10.2 上午 考试
    10.1 考试 ..........
    9.29 考试
    博弈论笔记
    bzoj_1022: [SHOI2008]小约翰的游戏John
    课程总结第十五周
    团队冲刺第二阶段09
    团队冲刺第二阶段08
    对搜狗输入法的评价
  • 原文地址:https://www.cnblogs.com/xiaoit/p/3376645.html
Copyright © 2011-2022 走看看