- 浏览: 243235 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (127)
- vim (3)
- python (44)
- pymysql (1)
- mysql (9)
- macvim (1)
- erlang (3)
- twisted (0)
- tornado (5)
- django (7)
- postgresql (5)
- sql (1)
- java (7)
- tech (4)
- cache (1)
- lifestyle (3)
- html (1)
- ubuntu (2)
- rabbitmq (1)
- algorithm (8)
- Linux (4)
- Pythonista (1)
- thread (1)
- sort (6)
- 设计模式 (1)
- search (1)
- Unix (6)
- Socket (3)
- C (2)
- web (1)
- gc (1)
- php (10)
- macos (1)
最新评论
-
2057:
这个程序有bug。
查找算法学习之二分查找(Python版本)——BinarySearch -
dotjar:
NB
一个Python程序员的进化[转]
引用
关系数据库中有三种基本的关系类型。根据关系双方所含对象的多少,可以将这些关系氛围一对一、一对多、多对多三种关系。
最少权限原则:
一个用户(或者一个进程)应该拥有能够执行分配给他的任务的最低级别的权限。
创建用户:GRANT命令
GRANT和REVOKE命令分别用来授予和取消MySQL用户的权限,这些权限分四个级别。他们分别是:
- 全局
- 数据库
- 表
- 列
mysql> help grant; Name: 'GRANT' Description: Syntax: GRANT priv_type [(column_list)] [, priv_type [(column_list)]] ... ON [object_type] priv_level TO user_specification [, user_specification] ... [REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}] [WITH with_option ...] GRANT PROXY ON user_specification TO user_specification [, user_specification] ... [WITH GRANT OPTION] object_type: TABLE | FUNCTION | PROCEDURE priv_level: * | *.* | db_name.* | db_name.tbl_name | tbl_name | db_name.routine_name user_specification: user [ IDENTIFIED BY [PASSWORD] 'password' | IDENTIFIED WITH auth_plugin [AS 'auth_string'] ] ssl_option: SSL | X509 | CIPHER 'cipher' | ISSUER 'issuer' | SUBJECT 'subject' with_option: GRANT OPTION | MAX_QUERIES_PER_HOUR count | MAX_UPDATES_PER_HOUR count | MAX_CONNECTIONS_PER_HOUR count | MAX_USER_CONNECTIONS count The GRANT statement grants privileges to MySQL user accounts. GRANT also serves to specify other account characteristics such as use of secure connections and limits on access to server resources. To use GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting. Normally, a database administrator first uses CREATE USER to create an account, then GRANT to define its privileges and characteristics. For example: CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass'; GRANT ALL ON db1.* TO 'jeffrey'@'localhost'; GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost'; GRANT USAGE ON *.* TO 'jeffrey'@'localhost' WITH MAX_QUERIES_PER_HOUR 90; However, if an account named in a GRANT statement does not already exist, GRANT may create it under the conditions described later in the discussion of the NO_AUTO_CREATE_USER SQL mode. The REVOKE statement is related to GRANT and enables administrators to remove account privileges. See [HELP REVOKE]. When successfully executed from the mysql program, GRANT responds with Query OK, 0 rows affected. To determine what privileges result from the operation, use SHOW GRANTS. See [HELP SHOW GRANTS]. URL: http://dev.mysql.com/doc/refman/5.5/en/grant.html
REVOKE命令
与GRANT相反的命令。用来从一个用户收回权限。
mysql> help revoke; Name: 'REVOKE' Description: Syntax: REVOKE priv_type [(column_list)] [, priv_type [(column_list)]] ... ON [object_type] priv_level FROM user [, user] ... REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ... REVOKE PROXY ON user FROM user [, user] ... The REVOKE statement enables system administrators to revoke privileges from MySQL accounts. Each account name uses the format described in http://dev.mysql.com/doc/refman/5.5/en/account-names.html. For example: REVOKE INSERT ON *.* FROM 'jeffrey'@'localhost'; If you specify only the user name part of the account name, a host name part of '%' is used. For details on the levels at which privileges exist, the permissible priv_type and priv_level values, and the syntax for specifying users and passwords, see [HELP GRANT] To use the first REVOKE syntax, you must have the GRANT OPTION privilege, and you must have the privileges that you are revoking. To revoke all privileges, use the second syntax, which drops all global, database, table, column, and routine privileges for the named user or users: REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ... To use this REVOKE syntax, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. URL: http://dev.mysql.com/doc/refman/5.5/en/revoke.html
例子:
mysql > grant all on * to eric identified by '123456' with grant option; mysql > revode all privileges, grant from eric;
创建一个没有任何权限的常规用户:
mysql > grant usage on books.* to sally identified by '123456';
授予权限
mysql > grant select,insert,update,delete,index,alter,create,drop on books.* to sally;
收回权限
mysql > revoke alter,create,drop on books.* from sally; mysql > revoke all on books.* from sally;
创建一个Web用户
授予增删改查的权限
mysql > grant select,insert,delete,update on books.* to user_a identified by '123456';
创建索引:
mysql> help create index; Name: 'CREATE INDEX' Description: Syntax: CREATE [ONLINE|OFFLINE] [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON tbl_name (index_col_name,...) [index_option] ... index_col_name: col_name [(length)] [ASC | DESC] index_type: USING {BTREE | HASH} index_option: KEY_BLOCK_SIZE [=] value | index_type | WITH PARSER parser_name | COMMENT 'string' CREATE INDEX is mapped to an ALTER TABLE statement to create indexes. See [HELP ALTER TABLE]. CREATE INDEX cannot be used to create a PRIMARY KEY; use ALTER TABLE instead. For more information about indexes, see http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html. URL: http://dev.mysql.com/doc/refman/5.5/en/create-index.html
SQL是什么
SQL全称是Structured Query Language。
表关联的总结
MySQL中的关联类型
名称 描述
- 笛卡尔儿乘积 所有表所有行的所有关联。实现方法,在列的名称之间指定一个逗号,而 不是指定一个WHERE字句。
- 完全关联 同上
- 交叉关联 同上,也可以通过在关联的表明之间指定CROSS JOIN关键词的指定。
- 内部关联 如果没有WHERE条件,等价于完全关联。
- 等价关联 在关联中使用一个带“=”号的条件表达式匹配来自不同表中的行。
- 左关联 试图匹配表的行并在不匹配的行中填入NULL,在SQL中使用LEFT JOIN关键词。
参考资料:
PHP&MySQL.Web
发表评论
-
MacOS PHP Warning: move_uploaded_file(): Unable to move '/private/var/tmp/phpgA
2013-09-06 11:45 3270引用Log into your ftp and confirm ... -
Learning PHP-MySQL高级管理
2013-08-28 23:45 1251引用mysql> use mysql Reading t ... -
Learning PHP-错误和异常处理
2013-08-28 23:37 835Try...Catch <?php try{ } ... -
Learning PHP-面向对象的PHP
2013-08-27 00:58 1208面向对象的开发方法试图在系统中引入对象的分类、关系和属性,从而 ... -
Learning PHP-代码重用和函数编写
2013-08-26 00:25 1112代码重用的好处: 在 ... -
Learning PHP-String与正则表达式
2013-08-26 00:22 1150字符串的格式化 字符串的整理:chop()、ltrim()和t ... -
Learning PHP-array
2013-08-21 19:12 975引用存储在数组中的值为数组元素。每个数组元素有一个相关的索引, ... -
Learning PHP -数据的存储与检索
2013-08-21 12:22 1240存储数据有两种基本方法:保存到普通文件,或者保存到数据库中。 ... -
Learning PHP -简介
2013-08-19 22:56 988PHP(PHP:Hypertext Preprocessor, ... -
索引的设计和使用
2013-08-11 16:55 934索引是数据库中用来提 ... -
MySQL支持的数据类型
2013-08-11 16:02 1673本文将介绍MySQL所支持的数据类型,内容整理于书籍。 1、数 ... -
B-tree索引和hash索引
2013-06-28 18:09 1521A B-tree index can be used for ... -
Mysql 存储引擎
2013-02-28 23:36 901MySQL支持的存储引擎包括MyISAM,InnoDB,BDB ... -
DDL、DML、DCL的一些操作
2012-06-26 23:53 9541、修改表类型,语法如下: ALTER TABLE ta ... -
mysql handler与select 性能比对
2011-10-27 17:47 1325mysql> create table test(i ... -
mysql handler操作
2011-10-27 16:19 4424HANDLER tbl_name OPEN [ [AS] ...
相关推荐
cn-deep-learning-vs-machine-learning-ebook(1)
MySQL 基础知识 * MySQL 是一种关系型数据库管理系统,主要用于存储和管理数据。 * MySQL 的主要特点是快速、稳定、可靠和安全。 * MySQL 的主要应用场景是 web 开发,包括博客、论坛、电子商务等。 JavaScript ...
Machine Learning End-to-End guide for Java developers 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
CoLight: Learning Network-level Cooperation for Traffic Signal Control
pytorch-Learning-to-See-in-the-Dark代码,CVPR论文 亲测,可行
Learning.PHP.MySQL.&.JavaScript.4th.Edition.2014.12.pdf
学习利用python实现数据的预处理的程序
21个例子学深度学习,tensorflow程序原代码Deep-Learning-21-Examples-master.21个项目玩转深度学习:基于tensorflow的实践详解
Deep-Learning-for-Beginners-master代码Deep-Learning-for-Beginners-master代码Deep-Learning-for-Beginners-master代码Deep-Learning-for-Beginners-master代码Deep-Learning-for-Beginners-master代码
Deep Reinforcement Learning Hands-On English | 21 Jun. 2018 | ISBN: 1788834240 | 546 Pages | EPUB | 12.69 MB
learning-spring-boot-2-0-2learning-spring-boot-2-0-2learning-spring-boot-2-0-2
开源e-learning软件---eConf
对深度强化学习的基本操作的程序。
Learning Non-Local Range Markov Random Field for Image Restoration, http://gr.xjtu.edu.cn/web/jiansun/4
Springer chapter A Self-learning Anomaly-Based Web Application Firewall
深度学习方面经典问题分析,包含深度学习中文版教程,帮助初学者更好入门
Learning PHP, MySQL & JavaScript, 5th Edition.epub
美国亚马逊评价很好的一本强化学习书,全英文。Deep Reinforcement Learning Hands-On: Apply modern RL methods, with deep Q-networks, value iteration, policy gradients, TRPO, AlphaGo Zero and more