zoukankan      html  css  js  c++  java
  • mysql5.7版本开始创建用户需要create user

    mysql5.7版本开始创建用户需要create user

    5.7版本之后,直接使用:grant select on MySQL.test01 to hug@localhost; 是不行的,会报错:

    Error Code: 1133. Can't find any matching row in the user table

    5.7版本创建用户需要这样:

     CREATE USER hug@localhost IDENTIFIED BY '123456';

     grant all on mysql.* to hug@localhost;

    官方文档是这样给的:

    The preferred method is to use account-management statements because they are more concise and less
    error-prone than manipulating the grant tables directly. All such statements are described in Section 13.7.1,
    “Account Management Statements”. Direct grant table manipulation is discouraged, and is not described
    here. The server is free to ignore rows that become malformed as a result of such modifications.
    Another option for creating accounts is to use the GUI tool MySQL Workbench. Also, several third-party
    programs offer capabilities for MySQL account administration. phpMyAdmin is one such program.
    The following examples show how to use the mysql client program to set up new accounts. These
    examples assume that privileges have been set up according to the defaults described in Section 2.10.4,
    “Securing the Initial MySQL Accounts”. This means that to make changes, you must connect to the MySQL
    server as the MySQL root user, which has the CREATE USER privilege.
    First, use the mysql program to connect to the server as the MySQL root user:
    shell> mysql --user=root mysql
    If you have assigned a password to the root account, you must also supply a --password or -p option.
    After connecting to the server as root, you can add new accounts. The following example uses CREATE
    USER and GRANT statements to set up four accounts:
    mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'

  • 相关阅读:
    用外部表的方式查询当天数据库alert日志文件
    比较数据泵和exp/imp对相同数据导出/导入的性能差异
    理解Oracle TM和TX锁
    Rocky4.2下安装金仓v7数据库(KingbaseES)
    理解listagg函数
    sql*loader的直接加载方式和传统加载方式的性能差异
    Rocky4.2下安装达梦(DM)6数据库
    演示对sys用户和普通用户进行审计的示例
    演示一个通过触发器进行审计的示例
    演示一个使用db vault进行安全控制的示例
  • 原文地址:https://www.cnblogs.com/tyxa/p/6564286.html
Copyright © 2011-2022 走看看