mysql 用户创建,授权
关于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的系统权限相关表方可生效
本文来自于:https://www.cnblogs.com/candle806/p/4048651.html
mysql 用户创建,授权的更多相关文章
- mysql用户创建授权
创建用户: grant select,update,insert,delete,create,drop,alter,index on *.* to 'jyx_mysql'@'%' identified ...
- mysql用户创建触发器权限不足跟参数log_bin_trust_function_creators
问题描述 有业务反馈当前用户无法创建触发器和存储过程,让用户自己测试,该用户进行对表的增删改查等其他权限没有问题,这边用root用户查证,该用户拥有对当前库的所有权限,但是为什么就是创建不了触发器呢? ...
- mysql用户创建与授权
一. 创建用户 命令: CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 说明: username:你将创建的用户名 host:指定该用户 ...
- mysql用户创建及授权
一. 创建用户: 命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 说明:username - 你将创建的用户名, host - 指 ...
- MySQL 用户与授权管理详解
大纲 一.前言 二.创建用户并授权 三.GRANT语句的种类 四.撤权并删除用户 一.前言 做为Mysql数据库管理员管理用户账户,是一件很重要的事,指出哪个用户可以连接服务器,从哪里连接,连接后能做 ...
- mysql 用户创建,修改和忘记root密码的操作
#创建用户CREATE USER 'zzq'@'localhost' IDENTIFIED by 'zzq';#flush privileges 命令本质上的作用是将当前user和privilige表 ...
- MySQL的学习--用户创建授权
前一段时间,将项目改成SAAS的架构,每个billing account都可以获得一个子域,一个单独的数据库,一个单独的数据库用户和对应数据库的权限. 现在有时间了,将数据库相关的命令用博客备份一下. ...
- 003:MySQL账号创建授权以及Workbench
目录 一. 权限管理 1."用户 + IP"的概念 2. 用户权限管理 3. 基本操作 4. 撤销权限 5.授权和创建用户 二. MySQL模拟角色 三. Workbench与Ut ...
- mysql用户和授权
CREATE USER 'monitor'@'10.224.32.%' IDENTIFIED BY '123@abAB'; mysql> GRANT select,insert,update O ...
随机推荐
- [LeetCode] 61. Rotate List 旋转链表
Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: I ...
- python:当文件中出现特定字符串时执行robot用例
#coding:utf-8 import os import datetime import time def execute_rpt_db_full_effe_cainiao_city(): fla ...
- public interface ICloneable
using System.Runtime.InteropServices; namespace System{ // // 摘要: // 支持克隆,即用与现有实例相同的值创建类的新实例. [ComVi ...
- PHPExcel 中文使用手册参数详解 三
设置excel的属性:创建人$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");最后修改人$ob ...
- Linq查询连接guid与varchar字段
使用场景 在数据库设计中进场会出现一些通用表,如通用附件表,一般都是通过ForeignTable(关联的表名)和ForeignKey(关联表的主键)与其他表关联.这样的表在数据库中没有外键关系,而且一 ...
- 14 SpringMVC框架的基本概念
1.三层架构 我们的开发架构一般都是基于两种形式,一种是 C/S 架构,也就是客户端/服务器,另一种是 B/S 架构,也就是浏览器服务器.在 JavaEE 开发中,几乎全都是基于 B/S 架构的开发. ...
- Mybatis中实体类属性与数据库列表间映射方法介绍
这篇文章主要介绍了Mybatis中实体类属性与数据列表间映射方法介绍,一共四种方法方法,供大家参考. Mybatis不像Hibernate中那么自动化,通过@Co ...
- 2019秋季PAT甲级_C++题解
2019 秋季 PAT (Advanced Level) C++题解 考试拿到了满分但受考场状态和知识水平所限可能方法不够简洁,此处保留记录,仍需多加学习.备考总结(笔记目录)在这里 7-1 Fore ...
- 屏蔽组合键[CTRL+N]
https://www.cnblogs.com/gaodu2003/archive/2011/05/05/2037229.html …… const _KeyPressMask=$80000000; ...
- 面试4 --- constructor必须与class同名,但方法不能与class同名?
选 C “constructor必须与class同名,但方法不能与class同名”这句话是错误的,方法是可以和class同名的:方法可以和类名同名的,和构造方法唯一的区别就是,构造方法没有返回值.