由于最近使用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 USERDROP USERRENAME 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 TOKILLPURGE BINARY LOGSSET 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 用户/密码/权限操作的更多相关文章

  1. MySql 用户 及权限操作

    bin/msyql -h host -u user -p    bin/mysql -u mysql -p  本地登录 如无密码按回车直接进入mySql   bin/mysqladmin -u roo ...

  2. mysql用户与权限操作

    本文所有操作均在mysql8.1下验证,mysql5.x部分语句不适用. 1.创建用户 '; # 创建用户test,密码123456,%表示允许在所有主机登陆 用户表为mysql库小的user表,Ho ...

  3. Mysql 用户,权限管理的几点理解。

    前两天项目数据库要移植到mysql,为此临时抓了几天很久没用的mysql. 公司的数据库比较简单,从oracle迁移到mysql很简单,但是,中间的权限管理让我感觉既简单又复杂..简单是因为网上关于m ...

  4. mysql 用户及权限管理 小结

    MySQL 默认有个root用户,但是这个用户权限太大,一般只在管理数据库时候才用.如果在项目中要连接 MySQL 数据库,则建议新建一个权限较小的用户来连接. 在 MySQL 命令行模式下输入如下命 ...

  5. 如何给mysql用户分配权限+增、删、改、查mysql用户

    在mysql中用户权限是一个很重析 参数,因为台mysql服务器中会有大量的用户,每个用户的权限需要不一样的,下面我来介绍如何给mysql用户分配权限吧,有需要了解的朋友可参考. 1,Mysql下创建 ...

  6. 入门MySQL——用户与权限

    前言:  前面几篇文章为大家介绍了各种SQL语法的使用,本篇文章将主要介绍MySQL用户及权限相关知识,如果你不是DBA的话可能平时用的不多,但是了解下也是好处多多. 1.创建用户 官方推荐创建语法为 ...

  7. MySQL Study之--MySQL用户及权限管理

    MySQL Study之--MySQL用户及权限管理     MySQLserver通过MySQL权限表来控制用户对数据库的訪问.MySQL权限表存放在mysql数据库里.由mysql_install ...

  8. linux中重置服务器的mysql用户密码

    本文章前提条件是自己经把mysql登录密码给忘记了,这个时间我们解决方法有很多,重新安装mysql数据库一切重来,另一种是通过下面文章重新设置root密码,下面我们一起来看看方法二吧.     最 近 ...

  9. SQL语句修改MySQL用户密码

    SQL语句修改MySQL用户密码 前言 上数据库安全实验课,用命令行和DataGrip试图修改用户密码,一直语法报错.最后用Navicat才修改成功,预览Navicat的SQL语句,发现语句和网上都不 ...

随机推荐

  1. C 语言 register 关键字

    register:这个关键字请求编译器尽可能的将变量存在CPU内部寄存器中,而不是通过内存寻址访问,以提高效率.注意是尽可能,不是绝对.你想想,一个CPU 的寄存器也就那么几个或几十个,你要是定义了很 ...

  2. Linux用户组相关指令

    ⒈增加用户组 ①groupadd 用户组名 ⒉删除用户组 ①groupdel 用户组名 ⒊修改用户所在的用户组 ①usermod -g 用户组 用户名 ★用户和用户组的相关文件 ①/etc/passw ...

  3. SpringBoot定制错误的Json数据

    (1)自定义异常处理&返回定制Json数据 @ControllerAdvice public class MyExceptionHandler { @ResponseBody @Excepti ...

  4. linux 串口0x03,0x13的问题【转】

    linux 串口0x03,0x13的问题 本人最近在调linux串口的时候,发现其他数据接收正常,但是0x13怎么也接收不到,后面发现了这篇文章,两天的bug终于解决了,原来是linux底层uart配 ...

  5. 【译】.NET Core 2.2 Preview 2 发布

    原文出自.Net Blog Announcing .NET Core 2.2 Preview 2 今天,我们宣布推出.NET Core 2.2 Preview 2.我们有很多重要改进要和你分享,而且我 ...

  6. Github简介

    先附上下载地址 http://windows.github.com/ git-scm.com是版本控制软件Git的官方网站. Git和GitHub的区别 Git是一个分布式的版本控制系统,与SVN类似 ...

  7. WDS 三种模式

    (1)懒人模式(Lazy mode) 此模式下不需要填写对端的BSSID,本端AP的WDS连接作为被动连接,只需要对端填写了本端AP的BSSID即可,效果和桥接模式一样. (2)桥接模式(Bridge ...

  8. CentOS 6.5自动化运维之基于cobbler服务的自动化安装操作系统详解

    一.Cobbler安装 前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可进行类似下面的安装过程. # yum install -y epel-release # yum ...

  9. JetBrains 授权服务器(License Server URLS)

    分享几个已经部署好的在线验证服务器:http://idea.iteblog.com/key.php http://idea.imsxm.com/ http://103.207.69.64:1017 h ...

  10. Dubbo入门---搭建一个最简单的Demo框架

    参考文档: https://blog.csdn.net/noaman_wgs/article/details/70214612/