• 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字段中添加内容,则在创建或者删除时必须加上@"该内容"(%除外)。

  • 相关阅读:
    枚举转中文,通过反射方法与描述的方式获取
    PropertyGrid 重难点总结
    Image与Bitmap的区别及相互转换
    A generic error occurred in GDI+的解决方案
    C# 鼠标穿透窗体与恢复
    struts2 validate验证
    Struts2 | struts.xml文件中使用method属性和通配符简化action标签和Action处理类的编写
    struts2中struts.xml和web.xml文件解析及工作原理
    Struts2中Struts.xml的作用
    <a>标签是什么意思 怎么使用?
  • 原文地址:https://www.cnblogs.com/xiaoit/p/3376645.html
Copyright © 2020-2023  润新知