MySQL管理.md
用户管理
创建
举例
mysql> create user test@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user where user='test';
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| test | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)
设置与更改用户密码
举例一
mysql> set password for test@localhost =password('redhat');
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user where user='test';
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| test | localhost | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)
举例二
mysql> update mysql.user set password=password('password') where user='test'and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,password from mysql.user where user='test';
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| test | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)
删除用户
举例一
mysql> select user,host,password from mysql.user;
+------+-------------+-------------------------------------------+
| user | host | password |
+------+-------------+-------------------------------------------+
| root | localhost | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | node3 | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| root | 127.0.0.1 | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| root | 192.168.%.% | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| test | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+------+-------------+-------------------------------------------+
5 rows in set (0.00 sec)
mysql> drop user root@node3;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-------------+-------------------------------------------+
| user | host | password |
+------+-------------+-------------------------------------------+
| root | localhost | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | 127.0.0.1 | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| root | 192.168.%.% | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| test | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+------+-------------+-------------------------------------------+
4 rows in set (0.04 sec)
举例二
mysql> delete from mysql.user where user='root' and host='127.0.0.1';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-------------+-------------------------------------------+
| user | host | password |
+------+-------------+-------------------------------------------+
| root | localhost | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | 192.168.%.% | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| test | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+------+-------------+-------------------------------------------+
3 rows in set (0.00 sec)
用户授权
语法
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
TO user_specification [, user_specification] ...
[REQUIRE {NONE | tsl_option [[AND] tsl_option] ...}]
[WITH {GRANT OPTION | resource_option} ...]
priv_level:
- * //所有
- *.* //所有库的所有对象
- db_name.* //指定库的所有对象
- db_name.tbl_name //指定库的指定表
- tbl_name //指定表
- db_name.routine_name //指定库的存储历程,包括存储过程和存储函数
举例一
mysql> grant all privileges on study.* to 'test'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'test'@'localhost';
+-------------------------------------------------------------------------------------------------------------+
| Grants for test@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `study`.* TO 'test'@'localhost' |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
说明: privileges 用户的操作权限,如SELECT , INSERT , UPDATE 等。如果要授予所的权限则使用ALL。
举例二
mysql> grant all privileges on study.* to 'test'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'test'@'localhost';
+-------------------------------------------------------------------------------------------------------------+
| Grants for test@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `study`.* TO 'test'@'localhost' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
例子一命令授权的用户不能给其它用户授权,如果想让该用户可以授权,用例子二命令。
举例三
mysql> grant all privileges on study.* to 'study'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user where user='study';
+-------+-----------+-------------------------------------------+
| user | host | password |
+-------+-----------+-------------------------------------------+
| study | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+-------+-----------+-------------------------------------------+
1 row in set (0.00 sec)
mysql> show grants for 'study'@'localhost';
+--------------------------------------------------------------------------------------------------------------+
| Grants for study@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'study'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `study`.* TO 'study'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
我们还可以在用户创建时就赋予其权限。
撤销权限
举例
mysql> revoke all privileges on study.* from 'study'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'study'@'localhost';
+--------------------------------------------------------------------------------------------------------------+
| Grants for study@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'study'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
+--------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
扩展:
http://blog.csdn.net/ithomer/article/details/5131863
http://www.cnblogs.com/hateislove214/archive/2010/11/05/1869889.html
MySQL管理.md的更多相关文章
- 使用mysql管理meta
第一部分 安装mysql 第二部分 使用mysql管理meta 安装mysql 安装 yum -y install mysql mysql-server yum方法安装需要使用网络:可以自动续传:对于 ...
- 15款最佳的MySQL管理工具和应用程序
工欲善其事,必先利其器.几乎每个开发人员都有最钟爱的 MySQL 管理工具,它帮助开发人员在许多方面支持包括 PostgreSQL,MySQL,SQLite,Redis,MongoDB 等在内的多种数 ...
- MYSQL管理之主从同步管理
原文地址:MYSQL管理之主从同步管理 作者:飞鸿无痕 MYSQL管理之主从同步管理 MYSQL主从同步架构是目前使用最多的数据库架构之一,尤其是负载比较大的网站,因此对于主从同步的管理也就显得非常重 ...
- MySQL管理之道:性能调优、高可用与监控内置脚本
MySQL管理之道:性能调优.高可用与监控内置脚本 随书附送脚本 keepalive配置文件和脚本开源工具pssh批量管理服务器(python) 下载地址 http://files.cnblogs.c ...
- mysql 管理工具
摘自: http://www.chinaz.com/free/2009/0306/68691.shtml MySQL是一个非常流行的小型关系型数据库管理系统,2008年1月16号被Sun公司收购.目前 ...
- Sequel Pro 免费的MySQL管理客戶端(有SSH部分)
官方站點:http://www.sequelpro.com Sequel Pro 的原名是 CocoaMySQL,是一个与 phpMyAdmin 類似的 MySQL 管理工具.它是由 Cocoa 和面 ...
- MySQL 管理
MySQL 管理 启动及关闭 MySQL 服务器 首先,我们需要通过以下命令来检查MySQL服务器是否启动: ps -ef | grep mysqld 如果MySql已经启动,以上命令将输出mysql ...
- 涂抹mysql笔记-mysql管理工具
五花八门的mysql管理工具<>mysql提供的命令行工具 mysql_install_db:mysql建库工具,在源码安装mysql环节我们使用过. mysql_safe:mysql启动 ...
- MySQL 管理之道读书总结
最近读了<MySQL 管理之道>一书,做了以下总结,希望对大家有所帮助.在这里非常感谢作者的辛勤付出. 影响 MySQL 性能的因素: 影响 MySQL InnoDB 引擎性能的最 ...
随机推荐
- Xshell 6 免费版本安装过程
下载 官网下载:https://www.netsarang.com/ 点击download 注册 填写下方红色方框标注的注册信息,注册类型填写“home or school use”,名字,邮箱.最后 ...
- 构造用于1个方法在多线程环境下重复多次执行测试的通用方法 C#
static void MultithreadsCycleTestWithSameMethod(int threadNumber, int cycleNumber, ThreadStart actio ...
- Netty面试
声明:此文章非本人所 原创,是别人分享所得,如有知道原作者是谁可以联系本人,如有转载请加上此段话 1.BIO.NIO 和 AIO 的区别? BIO:一个连接一个线程,客户端有连接请求时服务器端就需要 ...
- ManualResetEvent
ManualResetEvent是C#中一个比较常用的工具,可用于线程间通信,实现一种类似信号量的功能(不知道我这样描述是否恰当,有可能不是“类似”,而“就是”通过信号量来实现的,因为我也是最近才知道 ...
- web页面相关的一些常见可用字符介绍——张鑫旭
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1623 正文开始之前先 ...
- 谷歌浏览器network请求时间(stalled,DNS Lookup,Waiting)分析以及解决方案
network工具功能强大,能够让我看到网页加载的信息,比如加载时间,和先后顺序,是否是并行加载,还是堵塞加载. 默认情况下有八列: (1).Name:表示加载的文件名. (2).Method:表示请 ...
- Tomcat启动慢原因之一 At least one JAR was scanned for TLDs yet contained no TLDs
Tomcat启动时提示: 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging f ...
- Spring 中面向AOP之一系列做法
Spring的AOP实现是通过集成AspectJ框架实现的. 想必这句话大家都知道了吧,不知道也没关系,最起码你现在知道了. 四种实现方案,接下来我们一一去揭开它的神秘的面纱....... 第一种(伪 ...
- 转-超链接a的target属性
超链接a的target属性 <a>标签的target意思很明确就是在哪里打开目标文档. 第一种情况: 默认情况:当我们没有设置超链接属性target的value值时默认是_self,即&l ...
- 地图的可视化--Folium
1.安装folium pip install MarkupSafe-0.23-cp34-none-win_amd64.whl pip install Jinja2-2.8-py2.py3-none-a ...