• MySQL创建用户、授权、撤销权限、删除用户


    一、创建用户

    mysql -u root -p

      1.mysql->create user 'test'@'localhost' identified by '123';

      2.mysql->create user 'test'@'192.168.7.22' identified by '123';

      3.mysql->create user 'test'@'%' identified by '123';

    注意:此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。

    如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。也可以指定某台机器可以远程登录。

    如果报错:出现ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

    解决方法: 

      打开my.ini,查找 

      sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 

      修改为

      sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 

      然后重启MYSQL

    二、授权

    mysql -u root -p

      使用命令:grant privileges on databasename.tablename to 'username'@'host' identified by 'pwd';

      mysql->grant all on quant.* to 'test'@'localhost' identified by '123';

      mysql>flush privileges;

      如果授权报错:ERROR 1045 (28000): Access denied for user 'username'@'host' (using password: YES)

      参见:http://www.cnblogs.com/SZxiaochun/p/6962910.html

    三、撤销权限

    mysql -u root -p

      使用命令:revoke privileges on databasename.tablename from 'username'@'host';

      mysql>flush privileges;

    四、删除用户

    mysql -u root -p

      使用命令:drop user 'test'@'host';

  • 相关阅读:
    Django(进阶篇)之model
    RabbitMQ、Memcache、Redis(队列、缓存)
    AJAX总结
    数据库 MySql(二)
    Python操作mysql之SQLAchemy(ORM框架)
    Python操作Mysql
    Tornado框架
    Ubuntu 出现未定义的 curl_init 错误
    ubuntu下apache配置https且强制http转向为https 腾讯云
    Git fetch
  • 原文地址:https://www.cnblogs.com/SZxiaochun/p/6401424.html
Copyright © 2020-2023  润新知