zoukankan      html  css  js  c++  java
  • Mysql创建用户并授权

    运行命令行

    mysql -uroot -p

    登录mysql

    use mysql;

    创建用户:
    create user 'test123'@'localhost' identified by '12345';
    这里的test123表示User,localhost表示Host,12345表示authentication_string(密码)

    授权:
    grant all privileges on *.* to 'test123'@'localhost';
    这里的*.* 可以改成 testdb.*,testdb 表示具体的某一个库,testdb.*表示 testdb库的所有表
    这里的all privileges表示所有权限,权限分为:select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限
    所以这里也可以这样授权:
    grant select,insert,update,delete on *.* to 'test123'@'localhost';


    grant select,insert,update,delete,create,alter,drop on testdb.* to 'test123'@'localhost';

    撤消授权:

    revoke all on *.* from 'test123'@'localhost';

    刷新:

    flush privileges;

    做完增删改之后都要记得刷新授权

    查看用户操作权限:
    show grants for 'test123'@'localhost';

  • 相关阅读:
    函数的对称性及其图像变换
    KMP 字符串匹配
    15 保护模式中的特权级(上)
    每日总结
    每日总结
    每日总结
    每日总结
    每日总结
    每日总结
    2-26安卓自学
  • 原文地址:https://www.cnblogs.com/oukunqing/p/5836222.html
Copyright © 2011-2022 走看看