Last active
December 13, 2015 18:39
-
-
Save actaneon/4957144 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install | |
----------------- | |
brew install postgresql | |
initdb /usr/local/var/postgres | |
Startup | |
----------------- | |
# Required if using Launctl | |
If this is your first install, automatically load on login with: | |
mkdir -p ~/Library/LaunchAgents | |
cp /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ | |
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
If this is an upgrade and you already have the homebrew.mxcl.postgresql.plist loaded: | |
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
cp /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ | |
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
# Set in bashrc so don't have to specify on command line | |
export PGDATA=/usr/local/var/postgres | |
# Manual | |
pg_ctl start | stop | |
New DB | |
----------------- | |
createdb mcp_dev -O pair | |
# Query | |
----------------- | |
psql -d mcp_dev | |
\h - help | |
\q - quit | |
Show DBs / Tables / Columns | |
-------------------------------------- | |
mysql: SHOW DATABASES | |
postgresql: \l | |
postgresql: SELECT datname FROM pg_database; | |
mysql: SHOW TABLES | |
postgresql: \d | |
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'; | |
mysql: SHOW COLUMNS | |
postgresql: \d table | |
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table'; | |
mysql: DESCRIBE TABLE | |
postgresql: \d+ table | |
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table'; | |
Building New App | |
----------------- | |
rvm install 1.9.3 | |
gem install rails | |
rails new mcp -d postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment