zoukankan      html  css  js  c++  java
  • mysql 8.0.12 创建并授权出现的问题

    mysql 8.0.12 创建并授权出现的问题

    实际代码

    mysql> grant all privileges on database.* to 'user'@'localhost' identified by 'password';
    

    异常信息

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password'' at line 1
    

    解决方案

    将用户创建过程和授权过程分开

    mysql> create user 'luffy'@'localhost' identified by  'luffy';
    Query OK, 0 rows affected (0.04 sec)
    
    mysql> grant all privileges on luffy.* to 'luffy'@'localhost' with grant option;
    Query OK, 0 rows affected (0.09 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)
    

    flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里

    创建用户::create user ‘用户名’@‘访问主机’ identified by ‘密码’;
    授予权限:grant 权限列表 on 数据库 to ‘用户名’@‘访问主机’ ;
    with grant option这个选项表示该用户可以将自己拥有的权限授权给别人

  • 相关阅读:
    数据库查询(二)
    数据库插入操作
    java关键字查询数据库
    登录页面设计
    获取下拉列表的值
    Linux下tomcat 8安装与配置
    CentOS7下防火墙的设置
    centos 7 下nginx的安装
    vmware14下centos 7的安装和配置
    Linux中JDK的安装以及配置
  • 原文地址:https://www.cnblogs.com/9527mwz/p/11200643.html
Copyright © 2011-2022 走看看