【数据库】Mysql 创建用户与授权
Mysql 创建用户与授权
1. 创建用户:
CREATE USER 'username'@'host' [IDENTIFIED BY 'password'];
username:要创建的用户名;
host:代表地址;任何地址可以使用%
IDENTIFIED BY 'password':设置密码,如果不写则为空密码
eg:
CREATE USER 'root'@'localhost' IDENTIFIED BY '123';
CREATE USER 'root'@'%' IDENTIFIED BY '123';
2、授权:
GRANT privileges ON dbName.tableName TO 'username'@'host' [WITH GRANT OPTION];
privileges:用户的操作权限,如select, delete, update等,共14个。
dbname:数据库名
tablename:表名
WITH GRANT OPTION: 被授权的用户可以将他的拥有的权限授给其他用户
若要授权用户对所有数据库和表的相应操作权限可以用*表示,如*.*。
eg:
1. 查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to common_user@'%'
grant insert on testdb.* to common_user@'%'
grant update on testdb.* to common_user@'%'
grant delete on testdb.* to common_user@'%'
grant select, insert, update, delete on testdb.* to common_user@'%'2. 创建表、索引、视图、存储过程、函数等权限。
grant create on testdb.* to developer@'192.168.0.%';
grant alter on testdb.* to developer@'192.168.0.%';
grant drop on testdb.* to developer@'192.168.0.%';3. 操作外键权限。
grant references on testdb.* to developer@'192.168.0.%';4. 操作临时表权限。
grant create temporary tables on testdb.* to developer@'192.168.0.%';5. 操作索引权限。
grant index on testdb.* to developer@'192.168.0.%';6. 操作视图、查看视图源代码权限
grant create view on testdb.* to developer@'192.168.0.%';
grant show view on testdb.* to developer@'192.168.0.%';7. 操作存储过程、函数 权限
grant create routine on testdb.* to developer@'192.168.0.%'; -- now, can show procedure status
grant alter routine on testdb.* to developer@'192.168.0.%'; -- now, you can drop a procedure
grant execute on testdb.* to developer@'192.168.0.%';8. 管理数据库的权限。
grant all privileges on testdb to dba@'localhost'
其中,关键字 “privileges” 可以省略9. 管理所有数据库的权限。
grant all on *.* to dba@'localhost'查看当前用户(自己)权限:
show grants;查看其他用户权限:
show grants for dba@localhost;刷新授权,使之立即生效
flush privileges;
3、撤销用户权限
REVOKE privilege ON dbname.tablename FROM 'username'@'host';
revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;
4、设置和更改用户密码
SET PASSWORD FOR 'username'@'host'=PASSWORD('your_password');
alter user 'username'@'host' identified by 'your_password';
5、删除用户:
DROP USER 'username'@'host';
【数据库】Mysql 创建用户与授权相关推荐
- python 全栈开发,Day63(子查询,MySQl创建用户和授权,可视化工具Navicat的使用,pymysql模块的使用)...
昨日内容回顾 外键的变种三种关系:多对一:左表的多 对右表一 成立左边的一 对右表多 不成立foreign key(从表的id) refreences 主表的(id)多对多建立第三张表(foreign ...
- centos的mysql怎么删用户_linux/centos给Mysql创建用户、授权、查看、删除、修改密码、撤...
linux/centos给Mysql创建用户.授权.查看.删除.修改密码.撤 linux/centos给Mysql创建用户.授权.查看.删除.修改密码.撤销权限 linux/centos给Mysql创 ...
- MySQL创建用户并授权
MySQL创建用户并授权 创建用户 使用 命令创建 #使用 CREATECREATE USER 'testDatabase'@'%' IDENTIFIED BY '111111'; # CREATE ...
- centos 7 mysql 创建用户_【CentOS 7MySQL常用操作4】,MySQL创建用户以及授权#180116
hellopasswd MySQL创建用户以及授权 grant all on . to 'user1' identified by 'passwd'; grant SELECT,UPDATE,INSE ...
- MySQL创建数据库与创建用户以及授权
1.create schema [数据库名称] default character set utf8 collate utf8_general_ci;--创建数据库 采用create schema和c ...
- mysql 创建用户并授权_教你MySQL-8.0.x数据库授权
Mysql安装成功后,默认的root用户密码为空,你可以使用以下命令来创建root用户的密码: [root@host]# mysqladmin -u root password "new_p ...
- mysql豹_MySQL创建数据库与创建用户以及授权 小帅豹
1.create schema [数据库名称] default character set utf8 collate utf8_general_ci;--创建数据库 采用create schema和c ...
- MySQL创建用户与授权方法
一, 创建用户: 命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 说 明:username - 你将创建的用户名, host - ...
- mysql 创建用户、授权、修改密码
以下操作都要在mysql所在机器操作 一.创建用户 CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456'; 或 insert into mysql. ...
最新文章
- python模拟键盘输入字符_Python | 根据关键字符串遍历窗口 模拟键盘输入操作
- Oracle控制文件的重建
- “一次性”小家电之死:互联网必是杀手
- 用mysqlbinlog查看row格式的事件
- python安装第三方库win10_在win里anaconda怎么安装第三方的库
- SAP UI5应用访问OData metadata的url和Destination
- Linux 使用 jstat 命令查看 jvm 的 GC 情况
- 解决AttributeError AttributeError: 'NoneType' object has no attribute 'filename'
- 读懂Java代码总结
- 【clickhouse】clickhouse 配置 安装目录
- 怎么用鼠标选中java中table的某一行_为什么同事的工作效率那么高?学会这些鼠标双击技巧,你也可以的...
- ios 对日期的处理(包括计算昨天时间、明天时间)
- 语言输出奇树有多少总方法_新手如何快速学习一门编程语言?了解 TA,三周学好C语言...
- 微信扫码支付、聚合支付
- 如何在电脑上给视频去水印
- 针对部分软件无法开机自启动情况的解决措施(已解决)
- cdr添加节点快捷键_【CDR干货】常用cdr快捷键命令汇总,快来收藏!
- EPLAN 教育版超详细安装说明
- 计算机试题九,2017年职称计算机考试Excel测验试题(九)
- OkHttp超时时间设置