SSH to the vagrant OS command line.
Terminal $> vagrant ssh
Login to postgres database as vagrant user with the psql client:
vagrant@rails-dev-box: psql -U vagrant postgres
Decide on a username and password you want to use for your database.
Now we'll create this user with psql (in this example we'll be using "coderelf" as our username). Replace coderelf and ‘password’ with your own choices then run this statement:
postgres=# CREATE USER coderelf WITH CREATEDB PASSWORD 'password';
Give the new user permissions on all databases. Replace coderelf with your chosen username:
postgres=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO coderelf;
Exit psql by typing:
;\q
Update database.yml with your newly created username and password:
development:
…
username: coderelf
password: password
test:
…
username: coderelf
password: password
Finally create the new databases by running:
rake db:create
If this was successful, there won’t be any output. Double-check it was successful by running rake db:create
again (yes, again). You should see 2 lines printed out similar to:
database_name_development already exists
database_name_test already exists
Optional, only do this if you see an error like:
PG InvalidParameterValue ERROR new encoding UTF8 is incompatible with the encoding of the template database SQL_ASCII
HINT Use the same encoding as in the template database or use template0 as template
then specify the template option in database.yml for both development and test databases as follows:
development:
…
template: template0
test:
…
template: template0
If anyone has a way to do this using puppet with rails-dev-box, please share.