Last active
August 29, 2015 14:17
-
-
Save satomixx/2b6d60dbf04a07a91a9d to your computer and use it in GitHub Desktop.
MacOSX YosemiteでRails4.xを動かして、Postgresと繋げるときのメモ ref: http://qiita.com/tsumekoara/items/1c19052360864204c4f1
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
default: &default | |
# adapter: mysql2 | |
adapter: postgresql | |
encoding: utf8 | |
pool: 5 | |
# username: root | |
username: hoge | |
password: | |
# socket: /tmp/mysql.sock | |
development: | |
<<: *default | |
database: hoge_development | |
test: | |
<<: *default | |
database: hoge_test | |
production: | |
<<: *default | |
database: hoge_production | |
password: <%= ENV['HOGE_DATABASE_PASSWORD'] %> |
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
postgres=# create role hoge createdb replication superuser createrole login |
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
postgres=# \du | |
List of roles | |
Role name | Attributes | Member of | |
-----------+------------------------------------------------+----------- | |
postgres | Superuser, Create role, Create DB, Replication | {} | |
hoge | Superuser, Create role, Create DB, Replication | {} |
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
$ rake db:create |
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
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"utf8", "pool"=>5, "username"=>"hoge", "password"=>nil, "database"=>"hoge_development"} | |
PG::InsufficientPrivilege: ERROR: permission denied to create database | |
: CREATE DATABASE "matcha_test" ENCODING = 'utf8' |
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
$ sudo -u postgres -iPassword: | |
postgres$ psql | |
psql (9.4.1, server 9.4.0) | |
Type "help" for help. | |
postgres=# \l | |
List of databases | |
Name | Owner | Encoding | Collate | Ctype | Access privileges | |
--------------------+----------+----------+---------+-------+----------------------- | |
hoge_development | hoge | UTF8 | C | C | | |
hoge_test | hoge | UTF8 | C | C | |
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
$ psql -U hoge -d hoge_development | |
psql (9.4.1, server 9.4.0) | |
Type "help" for help. | |
hoge_development=> |
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
$ rails dbpsql (9.4.1, server 9.4.0) | |
Type "help" for help. | |
hoge_development=> |
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
$ rake db:migrate |
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
$ rails c |
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
$ rails c |
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
$ rails s | |
=> Booting WEBrick | |
=> Rails 4.2.0 application starting in development on http://localhost:3000 | |
=> Run `rails server -h` for more startup options | |
=> Ctrl-C to shutdown server | |
Exiting | |
bin/rails:6: warning: already initialized constant APP_PATH | |
/Users/hoge/bin/rails:6: warning: previous definition of APP_PATH was here | |
Usage: rails COMMAND [ARGS] | |
The most common rails commands are: | |
generate Generate new code (short-cut alias: "g") | |
console Start the Rails console (short-cut alias: "c") | |
server Start the Rails server (short-cut alias: "s") | |
dbconsole Start a console for the database specified in config/database.yml | |
(short-cut alias: "db") | |
new Create a new Rails application. "rails new my_app" creates a | |
new application called MyApp in "./my_app" | |
In addition to those, there are: | |
destroy Undo code generated with "generate" (short-cut alias: "d") | |
plugin new Generates skeleton for developing a Rails plugin | |
runner Run a piece of code in the application environment (short-cut alias: "r") | |
All commands can be run with -h (or --help) for more information. |
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
$ rake rails:update:bin |
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
$ bin/spring binstub --remove --all | |
# GemfileからSpringの部分をコメントアウトして | |
$ bundle install |
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
$ rails db | |
psql: FATAL: role "hoge" does not exist |
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
$ sudo su - postgres | |
or | |
$ sudo -u postgres -i |
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
postgres$ psql | |
psql (9.4.1, server 9.4.0) | |
Type "help" for help. |
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
postgres-# \du | |
List of roles | |
Role name | Attributes | Member of | |
-----------+------------------------------------------------+----------- | |
postgres | Superuser, Create role, Create DB, Replication | {} |
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
#gem 'mysql2' | |
gem 'pg' | |
gem 'rails_12factor', group: :production |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment