Database
Jump to navigation
Jump to search
General
- http://en.wikipedia.org/wiki/Relational_database
- http://en.wikipedia.org/wiki/Relational_database_management_system
- http://en.wikipedia.org/wiki/SQL
- https://vimeo.com/56639635 - Michael 'Monty' Widenius - Author of the MySQL Server and MariaDB fork
SQL
MySQL
- Wikipedia:MySQL
- InnoDB is the default storage engine for MySQL
Commands
mysql -u username -ppassword -h hostname databasename basic connection
Account management
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass'; CREATE DATABASE [userdatabase]; GRANT all on [userdatabase].* TO '[username]'; [1]
SHOW GRANTS SHOW GRANTS FOR 'user'@'localhost';
create database wikidb; grant index, create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';
Create command list for showing user grants [2]
SELECT CONCAT("SHOW GRANTS FOR '",user,"'@'",host,"';") FROM mysql.user WHERE host!='localhost';
FLUSH privileges;
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('mypass');
mysqladmin -u user_name -h host_name password "newpwd"
- C.5.4.1. How to Reset the Root Password
- http://www.debian-administration.org/articles/442 UPDATE mysql.user SET
Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;
mysqld_safe --init-file=rootreset &
DB management
SHOW databases; USE [db name]; SHOW tables; 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 ;
13.8.1. DESCRIBE provides information about the columns in a table.
Security
Troubleshooting
- 4.6.7. mysqlbinlog — Utility for Processing Binary Log Files
SQLite
MariaDB
Clients
Web
phpMyAdmin
other
- Adminer - single php file
wget http://www.adminer.org/latest-mysql-en.php -O adminer.php wget http://www.adminer.org/latest-en.php -O adminer.php
Admin
mysqladmin create db_name
Backup
- http://dev.mysql.com/doc/refman/5.0/en/mysqlhotcopy.html
- http://www.mysqldumper.net/
- http://zmanda.com/backup-mysql.html
- http://www.percona.com/doc/percona-xtrabackup/manual.html?id=percona-xtrabackup:xtrabackup_manual
Replication
mysqldump
Tools
- dbdeploy is a Database Change Management tool.
- https://github.com/tanin47/php_db_migrate
- https://bitbucket.org/stepancheg/mysql-diff/wiki/Home
- 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."
- anywhereindb - Sometime we need to find out a small piece of string in big Database. Like where is the configuration is saved, or where is Jon's Date of birth is saved. This code is search all the tables and all the rows and columns in a MYSQL Database. The code is written in PHP. For faster result, we are only searching in the varchar field.
- http://sourceforge.net/projects/ajaxmytop/ - monitoring
Scripts
- Search Replace DB - This script was made to aid the process of migrating PHP and MySQL based websites. It has additional features for WordPress but works for most other similar CMSes.
./searchreplacedb2cli.php --host localhost --user root --database test --pass "pass" --charset utf\-8 --search "findMe" --replace "replaceMe" --dry-run
Performance
PostgreSQL
- http://www.craigkerstiens.com/2012/04/30/why-postgres/
- http://www.wikivs.com/wiki/MySQL_vs_PostgreSQL
- http://wekeroad.com/2012/07/19/postgresql-rising
- https://speakerdeck.com/u/craigkerstiens/p/postgres-demystified
Redis
See also Server#Redis
Used in the BOA stack for caching.
CouchDB
Couchbase
MongoDB
- http://snmaynard.com/2012/10/17/things-i-wish-i-knew-about-mongodb-a-year-ago/
- http://blog.serverdensity.com/does-everyone-hate-mongodb/
JavaScript
Other
- http://radar.oreilly.com/2012/02/nosql-non-relational-database.html - http://news.ycombinator.com/item?id=3610844