Last active
September 4, 2018 19:54
-
-
Save vedant1811/eb4bf07f81471bb325d11541e1da55e0 to your computer and use it in GitHub Desktop.
Setup postgres for rails dev (mac & ubuntu)
This file contains hidden or 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
default: &default | |
adapter: postgresql | |
encoding: unicode | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
timeout: 5000 | |
host: localhost | |
username: rails | |
password: rails | |
development: | |
<<: *default | |
database: bowling_development | |
test: | |
<<: *default | |
database: bowling_test |
This file contains hidden or 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
$ brew install postgresql | |
$ brew services start postgresql | |
==> Tapping homebrew/services | |
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'... | |
remote: Counting objects: 14, done. | |
remote: Compressing objects: 100% (10/10), done. | |
remote: Total 14 (delta 0), reused 7 (delta 0), pack-reused 0 | |
Unpacking objects: 100% (14/14), done. | |
Tapped 1 command (44 files, 58.4KB). | |
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql) | |
$ psql postgres |
This file contains hidden or 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
postgres=# create user rails with password 'rails'; | |
CREATE ROLE | |
postgres=# alter role rails superuser createrole createdb replication; | |
ALTER ROLE | |
<CTRL+D to exit cli> | |
$ rails db:create | |
Created database 'bowling_development' | |
Created database 'bowling_test' |
This file contains hidden or 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
$ sudo apt install postgresql postgresql-contrib | |
$ sudo -u postgres psql | |
postgres=# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment