Difference between revisions of "Database"

From Things and Stuff Wiki
Jump to navigation Jump to search
Line 27: Line 27:
 
* http://www.pantz.org/software/mysql/mysqlcommands.html
 
* http://www.pantz.org/software/mysql/mysqlcommands.html
  
http://dev.mysql.com/doc/refman/5.6/en/create-user.html
+
==== Account management ====
 +
* [http://dev.mysql.com/doc/refman/5.1/en/account-management-sql.html Account Management Statements
  
  [http://dev.mysql.com/doc/refman/5.6/en/show.html show] databases;
+
  [http://dev.mysql.com/doc/refman/5.6/en/create-user.html CREATE USER ]'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
show tables;
 
 
   
 
   
[http://dev.mysql.com/doc/refman/5.6/en/use.html use] [db name];
+
  [http://dev.mysql.com/doc/refman/5.6/en/grant.html GRANT] all on userdatabase.* TO 'username'; [http://www.softwareprojects.com/resources/programming/t-how-to-restrict-mysql-user-access-to-a-single-datab-1734.html]
 
[http://dev.mysql.com/doc/refman/5.6/en/flush.html flush] privileges;
 
 
 
  [http://dev.mysql.com/doc/refman/5.6/en/grant.html grant] all on userdatabase.* TO 'username'; [http://www.softwareprojects.com/resources/programming/t-how-to-restrict-mysql-user-access-to-a-single-datab-1734.html]
 
 
   
 
   
 
  [http://dev.mysql.com/doc/refman/5.6/en/show-grants.html 13.7.5.17. SHOW GRANTS Syntax]
 
  [http://dev.mysql.com/doc/refman/5.6/en/show-grants.html 13.7.5.17. SHOW GRANTS Syntax]
 
http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
 
  
 
Create command list for showing user grants [http://www.pythian.com/news/1165/creative-sql-how-to-easily-show-grants-for-many-users/]
 
Create command list for showing user grants [http://www.pythian.com/news/1165/creative-sql-how-to-easily-show-grants-for-many-users/]
 
  SELECT CONCAT("SHOW GRANTS FOR '",user,"'@'",host,"';") FROM mysql.user WHERE host!='localhost';
 
  SELECT CONCAT("SHOW GRANTS FOR '",user,"'@'",host,"';") FROM mysql.user WHERE host!='localhost';
  
 +
[http://dev.mysql.com/doc/refman/5.6/en/flush.html FLUSH] privileges;
 +
 +
==== DB management ====
 +
[http://dev.mysql.com/doc/refman/5.6/en/show.html SHOW] databases;
 +
SHOW tables;
 +
 +
[http://dev.mysql.com/doc/refman/5.6/en/use.html USE] [db name];
 +
 
  SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
 
  SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
  
 +
* http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
 +
 +
==== Security ====
 +
* http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html
  
 
=== SQLite ===
 
=== SQLite ===

Revision as of 03:46, 21 July 2012


MySQL

Commands

Account management

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';

GRANT all on userdatabase.* TO 'username'; [1]

13.7.5.17. SHOW GRANTS Syntax

Create command list for showing user grants [2]

SELECT CONCAT("SHOW GRANTS FOR '",user,"'@'",host,"';") FROM mysql.user WHERE host!='localhost';
FLUSH privileges;

DB management

SHOW databases;
SHOW tables;

USE [db name];

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;

Security

SQLite

MariaDB

Web interfaces

Admin

mysqldump

Tools

  • dBug - "PHP version of ColdFusion’s cfdump. Outputs colored and structured tabular variable information. Variable types supported are: Arrays, Classes/Objects, Database and XML Resources."

Other