关于mysql的用户管理,笔记

  1、创建新用户

  通过root用户登录之后创建

  >> grant all privileges on *.* to testuser@localhost identified by "123456" ;  //  创建新用户,用户名为testuser,密码为123456 ;

  >> grant all privileges on *.* to testuser@localhost identified by "123456" ;  //  设置用户testuser,可以在本地访问mysql

  >> grant all privileges on *.* to testuser@"%" identified by "123456" ;   //  设置用户testuser,可以在远程访问mysql

  >> flush privileges ;  //  mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效

  

  2、设置用户访问数据库权限

  >> grant all privileges on test_db.* to testuser@localhost identified by "123456" ;  //  设置用户testuser,只能访问数据库test_db,其他数据库均不能访问 ;

  >> grant all privileges on *.* to testuser@localhost identified by "123456" ;  //  设置用户testuser,可以访问mysql上的所有数据库 ;

  >> grant all privileges on test_db.user_infor to testuser@localhost identified by "123456" ;  //  设置用户testuser,只能访问数据库test_db的表user_infor,数据库中的其他表均不能访问 ;

  

  3、设置用户操作权限

  >> grant all privileges on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;  //设置用户testuser,拥有所有的操作权限,也就是管理员 ;

  >> grant select on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;  //设置用户testuser,只拥有【查询】操作权限 ;

  >> grant select,insert on *.* to testuser@localhost identified by "123456"  ;  //设置用户testuser,只拥有【查询\插入】操作权限 ;

  >> grant select,insert,update,delete on *.* to testuser@localhost identified by "123456"  ;  //设置用户testuser,只拥有【查询\插入】操作权限 ;

  >> REVOKE select,insert ON what FROM testuser  //取消用户testuser的【查询\插入】操作权限 ;

  

  4、设置用户远程访问权限

  >> grant all privileges on *.* to testuser@“192.168.1.100” identified by "123456" ;  //设置用户testuser,只能在客户端IP为192.168.1.100上才能远程访问mysql ;

  

  5、关于root用户的访问设置

  设置所有用户可以远程访问mysql,修改my.cnf配置文件,将bind-address = 127.0.0.1前面加“#”注释掉,这样就可以允许其他机器远程访问本机mysql了;

  >> grant all privileges on *.* to root@"%" identified by "123456" ;   //  设置用户root,可以在远程访问mysql

  >> select host,user from user;   //查询mysql中所有用户权限

  关闭root用户远程访问权限

  >> delete from user where user="root" and host="%" ;  //禁止root用户在远程机器上访问mysql

  >> flush privileges ;  //修改权限之后,刷新MySQL的系统权限相关表方可生效  

修改mysql权限的更多相关文章

  1. 【mysql创建用户|删除用户|修改用户权限|常用命令】

    原文链接:http://blog.csdn.net/leili0806/article/details/8573636 1.       CREATE USER 语法: CREATE USER 'us ...

  2. 修改mysql允许主机访问的权限

    开启mysql的远程访问权限 默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限. 主流的有两种方法,改表法和授权法. 相对而言, ...

  3. mysql 权限的相应修改

    mysql 权限的相应修改 UPDATE user SET Password = PASSWORD('bbbb') WHERE user = 'root';flush privileges; upda ...

  4. MySQL 权限与安全

    一.MySQL权限系统通过两个阶段进行认证: (A) 对用户进行身份认证,IP地址和用户名联合, (B) 对合法用户赋予相应权限,权限表在数据库启动的时候载入内存中. 二.在权限的存取过程中,会用到& ...

  5. mysql权限与安全

    一.MySQL权限系统通过两个阶段进行认证: (A) 对用户进行身份认证,IP地址和用户名联合, (B) 对合法用户赋予相应权限,权限表在数据库启动的时候载入内存中. 二.在权限的存取过程中,会用到& ...

  6. MYSQL权限表user操作

        MYSQL权限表user cmd中进人mysql找到mysql安装目录     E:\wamp\bin\mysql\mysql5.6.12\bin>mysql.exe -u 用户名  - ...

  7. Windows如何修改MySQL用户root密码

    听语音 浏览:16925 | 更新:2015-06-12 14:49 | 标签:windows 1 2 3 4 5 6 分步阅读 MySQL是一个关系型数据库管理系统,在 WEB 应用方面 MySQL ...

  8. Mysql权限

    连接Oracle/Mysql数据库的配置 1.Oracle <context:property-placeholder location="jdbc.properties"/ ...

  9. 【MySQL学习笔记】MySQL权限表

    MySQL权限表,控制用户对数据库的访问,存在mysql数据库中,由mysql_install_db初始化,包括user,db,host,tables_priv,columns_priv,procs_ ...

随机推荐

  1. [牛客Wannafly挑战赛27D]绿魔法师

    description newcoder 给你一个空的可重集合\(S\). \(n\)次操作,每次操作给出\(x\),\(k\),\(p\),执行以下操作: \(opt\ 1\):在S中加入x. \( ...

  2. [洛谷P4139]上帝与集合的正确用法

    题目大意:多次询问,每次给你$p$询问$2^{2^{2^{\dots}}}\bmod p$ 题解:扩展欧拉定理,求出$\varphi(p)$即可.因为$2^{2^{2^{\dots}}}>> ...

  3. BZOJ1257:[CQOI2007]余数之和——题解+证明

    http://www.lydsy.com/JudgeOnline/problem.php?id=1257 Description 给出正整数n和k,计算j(n, k)=k mod 1 + k mod ...

  4. 解决jsp两种提交方式乱码 的方法

    解决中文乱码 ---post提交方式  需要在处理页面添加request.setCharacterEncoding("utf-8"); 制定请求的编码,调用一下request.ge ...

  5. PHP检测json格式数据

    首先要记住json_encode返回的是字符串, 而json_decode返回的是对象 判断数据不是JSON格式: 复制代码代码如下: function is_not_json($str){      ...

  6. python升级引发的问题总结

    http://www.cnblogs.com/ajianbeyourself/p/4214398.html http://www.cnblogs.com/hanggegege/p/6993003.ht ...

  7. 最新eclipse安装SVN插件

    转载自:http://welcome66.iteye.com/blog/1845176 eclipse里安装SVN插件,一般来说,有两种方式: 直接下载SVN插件,将其解压到eclipse的对应目录里 ...

  8. [LeetCode] 15. 3Sum ☆☆

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...

  9. 应用Xml.Linq读xml文件

    c#提供了System.Xml.Linq操作xml文件,非常方便,本文主要介绍如何应用System.Xml.Linq读取xml文件. xml文本 <?xml version="1.0& ...

  10. MSSQL Procudure Sample

    代码: USE [Internal_Timesheet] GO /****** Object: StoredProcedure [dbo].[ManageTSReminder] Script Date ...