---
title: "mysql用户"
author: "shuizhaosi888"
date: "2016-01-01T19:48:06Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2016-01-01T19:49:19Z"
id: 2268046
url: "https://flyouwith.iteye.com/blog/2268046"
---

**1.创建用户**

    

```
--创建用户
--格式：用户名@ip地址
--备注：'% 中的 '表示转义 ，%相当于like '%' 匹配所有地址

create user 'test2'@'%' identified by 'mima';
```

 

 

 **2.查看用户**

    

```
--查看用户
select user,host from mysql.user;
+-------+-----------+
| user  | host      |
+-------+-----------+
| test1 | %         |
| test2 | %         |
| root  | 127.0.0.1 |
| root  | ::1       |
|       | localhost |
| root  | localhost |
+-------+-----------+
```

 

    **3.查看用户权限**

       

```
show grants for test2;
| GRANT USAGE ON *.* TO 'test2'@'%' IDENTIFIED BY PASSWORD '*98703F7A543944FD3818077669F74D60616DB2C8' |

--备注：*.*  表示  所有库.所有表
```