博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL查看登录用户以及修改密码和创建用户以及授权
阅读量:4688 次
发布时间:2019-06-09

本文共 969 字,大约阅读时间需要 3 分钟。

1、mysql查看当前登录用户,当前数据库:

select user();select database();

2、修改root或其他用户密码

update mysql.user set password=password('新密码') where user='用户名';flush privileges; //此为刷新权限

3、建库

create database `库名` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

4、创建用户

新增用户,并只限本地登录insert into mysql.user(Host,User,Password) values("localhost","用户名",password("密码"));flush privileges; 新增用户,外网可登录insert into mysql.user(Host,User,Password) values("%","用户名",password("密码"));flush privileges;

5、授予用户通过外网IP对于该数据库的全部权限

grant all privileges on `库名或*`.* to '用户名'@'%' identified by '密码';  flush privileges;

6、授予用户在本地服务器对该数据库的全部权限

grant all privileges on `库名或*`.* to 'testuser'@'localhost' identified by 'userpasswd';  flush privileges;

7、针对test数据库创建一个无任何权限的用户

grant usage on test.* to zhangsan@localhost identified by 'zhangsan1';赋予某个权限grant select on test.* to zhangsan@localhost;

8、撤销一个用户对某数据库的所有权限

revoke all privileges on test.* from zhangsan@localhost;

 

转载于:https://www.cnblogs.com/deverz/p/6491924.html

你可能感兴趣的文章
数据库、C#、Java生成唯一GUID 方法
查看>>
gtest 安装
查看>>
sql中根据逗号分隔,查出多行数据
查看>>
js 回到頂部
查看>>
$ is not defined与SpringMVC访问静态资源
查看>>
第五周作业
查看>>
iphone中扫描wifi热点
查看>>
JavaScript中Array类型方法总结
查看>>
关于<input type="hidden"/>标签的记录
查看>>
C++ 类 & 对象
查看>>
ASP.NET Core 运行原理解剖[2]:Hosting补充之配置介绍
查看>>
007-JQuery 筛选
查看>>
部署java项目到阿里云服务器(centos7版本)
查看>>
MATLAB 动图绘制、保存
查看>>
前端设计说明书
查看>>
Java主类结构:变量与常量
查看>>
oracle Ebs database clone (no apps clone)
查看>>
7月新的开始 - Axure学习05 - 元件库的创建
查看>>
MS SQL计算最大公约数和最小公倍数函数
查看>>
爬虫scrapy框架安装使用
查看>>