zoukankan      html  css  js  c++  java
  • mysql 创建新用户并添加权限

    1、添加用户
      1.1 添加一个新用户:
      
    mysql>grant usage on *.* to 'sealy'@'localhost' IDENTIFIED by "123456" with grant option;

      上面这种只支持mysql服务器本地登录。

      1.2 添加一个任意Ip登录的用户:

    mysql>grant usage on *.* to 'sealy'@'%' IDENTIFIED by "123456" with grant option;

    2、授权test用户拥有testDB数据库的所有权限(某个数据库的所有权限):

      2.1 为某个用户授予所有权限:

    mysql>grant all privileges on testDB.* to 'test'@'%' identified by '123456';
    
    mysql>flush privileges;  --刷新系统权限表

      格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"; 

      2.2 为某个用户授予部分权限:

    mysql>grant select,update on 'testDB'.* to 'test'@'%' identified by '123456';
    mysql>flush privileges; 

      2.5 授权test用户拥有所有数据库的某些权限:   

    mysql>grant select,delete,update,create,drop on *.* to 'test'@'%' identified by "123456";

        --test用户对所有数据库都有select,delete,update,create,drop 权限。

      --@"%" 表示对所有非本地主机授权,不包括localhost。

      --对localhost授权:加上一句grant all privileges on testDB.* to 'test'@'localhost' identified by '123456';即可。

  • 相关阅读:
    1856: [Scoi2010]字符串(Catalan数)
    11.6NOIP模拟赛
    bzoj1257[CQOI2007]余数之和(除法分块)
    11.5NOIP模拟赛
    bzoj1048(记忆化搜索)
    置顶公告+更新日志
    CF585F Digits of Number Pi
    [SHOI2007]善意的投票
    [HEOI2015]最短不公共子串
    树形背包复杂度+P3177 [HAOI2015]树上染色
  • 原文地址:https://www.cnblogs.com/sixbeauty/p/4798276.html
Copyright © 2011-2022 走看看