Mysql创建用户并授权
2024-10-14 04:40:10
运行命令行
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';
最新文章
- 使用Xmanager访问CentOS远程桌面
- 移动端js知识总结
- PHP 线程安全与非线程安全版本的区别深入解析
- MongoDB增删查改
- Swift3.0语言教程比较、判断字符串
- 教你搞定Android自定义View
- VS2010中查询替换使用
- commoncrawl 源码库是用于 Hadoop 的自定义 InputFormat 配送实现
- STL内存管理
- C#如何连接wifi和指定IP
- javascript函数传值问题(传值?址)
- H5 34-背景图片
- 鼠标hover图片时遮罩层匀速上升显示内容top、定位
- 第三章 C#程序结构[3.2 选择结构的应用(Windows窗体应用程序)(四)]
- ExecuteNonQuery()
- svn中的ignore
- hadoop商业版本的选择介绍
- SharePoint 2013 Farm 安装指南——构建一个双层SharePoint Farm
- 按着shift键对dbgrid进行多条记录选择的问题(50分)
- Ice Cream Tower