mysql 用户/密码/权限操作
由于最近使用mysql遇到了修改用户密码的问题,所以一块学习了一下关于用户的相关操作;
1. 创建新账户
CREATE USER 'jeffrey'@'localhost';
2. 账户设置密码
#当前用户设置密码
SET PASSWORD = PASSWORD('mypass'); #给指定账户设置密码
SET PASSWORD FOR 'jeffrey'@'localhost' = PASSWORD('mypass');
3. 给账户赋权限
#赋权限
GRANT ALL ON db1.* TO 'jeffrey'@'localhost'; #刷新权限
flush privileges;
刷新权限的方式有多种,如上只是其中的一种方式。详情点击 或 如下:

可赋值的权限如下表:
Table 13.3 Permissible Privileges for GRANT and REVOKE
| Privilege | Meaning and Grantable Levels |
|---|---|
ALL [PRIVILEGES] |
Grant all privileges at specified access level except GRANT OPTION and PROXY. |
ALTER |
Enable use of ALTER TABLE. Levels: Global, database, table. |
ALTER ROUTINE |
Enable stored routines to be altered or dropped. Levels: Global, database, procedure. |
CREATE |
Enable database and table creation. Levels: Global, database, table. |
CREATE ROUTINE |
Enable stored routine creation. Levels: Global, database. |
CREATE TABLESPACE |
Enable tablespaces and log file groups to be created, altered, or dropped. Level: Global. |
CREATE TEMPORARY TABLES |
Enable use of CREATE TEMPORARY TABLE. Levels: Global, database. |
CREATE USER |
Enable use of CREATE USER, DROP USER, RENAME USER, and REVOKE ALL PRIVILEGES. Level: Global. |
CREATE VIEW |
Enable views to be created or altered. Levels: Global, database, table. |
DELETE |
Enable use of DELETE. Level: Global, database, table. |
DROP |
Enable databases, tables, and views to be dropped. Levels: Global, database, table. |
EVENT |
Enable use of events for the Event Scheduler. Levels: Global, database. |
EXECUTE |
Enable the user to execute stored routines. Levels: Global, database, table. |
FILE |
Enable the user to cause the server to read or write files. Level: Global. |
GRANT OPTION |
Enable privileges to be granted to or removed from other accounts. Levels: Global, database, table, procedure, proxy. |
INDEX |
Enable indexes to be created or dropped. Levels: Global, database, table. |
INSERT |
Enable use of INSERT. Levels: Global, database, table, column. |
LOCK TABLES |
Enable use of LOCK TABLES on tables for which you have the SELECT privilege. Levels: Global, database. |
PROCESS |
Enable the user to see all processes with SHOW PROCESSLIST. Level: Global. |
PROXY |
Enable user proxying. Level: From user to user. |
REFERENCES |
Enable foreign key creation. Levels: Global, database, table, column. |
RELOAD |
Enable use of FLUSH operations. Level: Global. |
REPLICATION CLIENT |
Enable the user to ask where master or slave servers are. Level: Global. |
REPLICATION SLAVE |
Enable replication slaves to read binary log events from the master. Level: Global. |
SELECT |
Enable use of SELECT. Levels: Global, database, table, column. |
SHOW DATABASES |
Enable SHOW DATABASES to show all databases. Level: Global. |
SHOW VIEW |
Enable use of SHOW CREATE VIEW. Levels: Global, database, table. |
SHUTDOWN |
Enable use of mysqladmin shutdown. Level: Global. |
SUPER |
Enable use of other administrative operations such as CHANGE MASTER TO, KILL, PURGE BINARY LOGS, SET GLOBAL, and mysqladmin debug command. Level: Global. |
TRIGGER |
Enable trigger operations. Levels: Global, database, table. |
UPDATE |
Enable use of UPDATE. Levels: Global, database, table, column. |
USAGE |
Synonym for “no privileges” |
4. 常用mysql命令
#查看当前用户
select current_user;
select current_user(); #格式化输出结果 字符/G 代表格式化输出
select * from t where t.id = 1/G;
5. 参考链接
1. https://dev.mysql.com/doc/refman/5.6/en/set-password.html
2. https://dev.mysql.com/doc/refman/5.7/en/create-user.html#create-user-previous
3. https://dev.mysql.com/doc/refman/5.6/en/grant.html
4. https://dev.mysql.com/doc/refman/5.7/en/privilege-changes.html
mysql 用户/密码/权限操作的更多相关文章
- MySql 用户 及权限操作
bin/msyql -h host -u user -p bin/mysql -u mysql -p 本地登录 如无密码按回车直接进入mySql bin/mysqladmin -u roo ...
- mysql用户与权限操作
本文所有操作均在mysql8.1下验证,mysql5.x部分语句不适用. 1.创建用户 '; # 创建用户test,密码123456,%表示允许在所有主机登陆 用户表为mysql库小的user表,Ho ...
- Mysql 用户,权限管理的几点理解。
前两天项目数据库要移植到mysql,为此临时抓了几天很久没用的mysql. 公司的数据库比较简单,从oracle迁移到mysql很简单,但是,中间的权限管理让我感觉既简单又复杂..简单是因为网上关于m ...
- mysql 用户及权限管理 小结
MySQL 默认有个root用户,但是这个用户权限太大,一般只在管理数据库时候才用.如果在项目中要连接 MySQL 数据库,则建议新建一个权限较小的用户来连接. 在 MySQL 命令行模式下输入如下命 ...
- 如何给mysql用户分配权限+增、删、改、查mysql用户
在mysql中用户权限是一个很重析 参数,因为台mysql服务器中会有大量的用户,每个用户的权限需要不一样的,下面我来介绍如何给mysql用户分配权限吧,有需要了解的朋友可参考. 1,Mysql下创建 ...
- 入门MySQL——用户与权限
前言: 前面几篇文章为大家介绍了各种SQL语法的使用,本篇文章将主要介绍MySQL用户及权限相关知识,如果你不是DBA的话可能平时用的不多,但是了解下也是好处多多. 1.创建用户 官方推荐创建语法为 ...
- MySQL Study之--MySQL用户及权限管理
MySQL Study之--MySQL用户及权限管理 MySQLserver通过MySQL权限表来控制用户对数据库的訪问.MySQL权限表存放在mysql数据库里.由mysql_install ...
- linux中重置服务器的mysql用户密码
本文章前提条件是自己经把mysql登录密码给忘记了,这个时间我们解决方法有很多,重新安装mysql数据库一切重来,另一种是通过下面文章重新设置root密码,下面我们一起来看看方法二吧. 最 近 ...
- SQL语句修改MySQL用户密码
SQL语句修改MySQL用户密码 前言 上数据库安全实验课,用命令行和DataGrip试图修改用户密码,一直语法报错.最后用Navicat才修改成功,预览Navicat的SQL语句,发现语句和网上都不 ...
随机推荐
- Maven入门-依赖管理(Jar包管理)(二)
1 依赖管理(Jar包管理) 1.添加依赖
- (原)tensorflow中使用指定的GPU及GPU显存
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6591923.html 参考网址: http://stackoverflow.com/questions ...
- javascript随笔和常见的知识点
1.js中循环中用 return只能停止循环,不能停止到函数的定义部分.所以下面的返回值为1 return 100没有意义,只起到终止循环的目的 function bb() { var sum = 0 ...
- ubuntu系统初始化网络及mysql配置
安装系统时需要安装open-ssh服务软件,否则无法远程连接 1.修改root密码 # sudo passwd 输入密码即可 切换到root用户,需要输入刚才的root密码 # su - 2.配置网络 ...
- Android数据存储:File
Android数据存储之File Files:它通过FileInputStream和FileOuputStream对文件进行操作.但是在Android中,文件是一个应用程序私有的,一个应用程序无法读写 ...
- curl, wget常用选项
使用指定的http代理,配合md5sum 对于检查源站与cdn节点资源是否一致很有效 curl -o a.jpg -x http://pbcdn.xximg1.com/v6/global2015/im ...
- vue系列之Vue-cli
Vue-cli是Vue的脚手架工具 vue-cli 地址:https://github.com/vuejs/vue-cli 安装 npm install -g vue-cli 使用 vue init ...
- STM32应用实例十:简析STM32 I2C通讯死锁问题
I2C接口是一种使用非常普遍的MCU与外部设备的接口方式,在STM32中也集成了I2C接口,我们也常常使用它来与外围的传感器等设备通讯. 最近在我们使用STM32F1VET6读取压力和温湿度传感器数据 ...
- LeetCode(28): 实现strStr()
Easy! 题目描述: 实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0 ...
- 目标检测-yolo2
转载自:http://blog.csdn.net/qq_34784753/article/details/78825493 对于现在的最好的检测系统来说,yolo_v1 的问题主要出现在两方面,也就是 ...