Reputation: 1285
Newbie to Postgres, basic skills with Rails, so bear with me.
I will explain the process of how I got to where I am, in case I did anything wrong along the way.
I created a Rails 5 project (using the actual Git repo) and, once it was created successfully, I found the default gem sqlite3
in the Gemfile.
Now, I want to work with Postgres, so I turned sqlite3
into pg
, and ran bundle install
. Worked perfectly, Rails didn't complain.
Then, I installed Postgres on my computer (using the latest OS X) and ran createdb testDB
. It's an empty database.
Now, I have to configure the database.yml file. After going through a dozen of links and resources, I changed the file's contents to the following:
default: &default
adapter: postgresql
database: testDB
username: postgres
password: password
host: localhost
port: 9057
development:
<<: *default
test:
<<: *default
production:
<<: *default
database: someOtherDB
I am certain that the port number is correct, because I set it manually, and I can check that it's running using the command netstat -na
. I get the following two lines:
tcp6 0 0 *.9057 *.* LISTEN
tcp4 0 0 *.9057 *.* LISTEN
Now, in order to change the password for postgres to ensure it's actually the cleverly secure string password
, I ran the following commands:
$ sudo -u postgres psql template1
Opens up the psql
prompt, then I run the command:
psql (9.3.4)
Type "help" for help.
template1=# ALTER USER postgres PASSWORD 'password';
Which returned:
ALTER ROLE
Yay! Password's changed! Now I can open up my first ever working Rails app with a Postgres backend!
I run bin/rails server
, and I get the following error:
When I run the command psql -l
, I get the following:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------------+----------+-------------+-------------+-------------------------------
postgres | myusername | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | myusername | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/myusername +
| | | | | myusername=CTc/myusername
template1 | myusername | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/myusername +
| | | | | myusername=CTc/myusername
test | myusername | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
testDB | myusername | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
(5 rows)
If I run psql X
(where X is any of the databases listed above) followed by running the command \du
, I get the following.
List of roles
Role name | Attributes | Member of
--------------+------------------------------------------------+-----------
myusername | Superuser, Create role, Create DB, Replication | {}
postgres | Superuser | {}
I followed instructions on this link and a few others to no avail.
What am I doing wrong?
Thank you so much in advance.
EDIT:
Here's the content of log/development.log
.
Upvotes: 1
Views: 2307
Reputation: 34657
The default login for rails is the current username logged in and a blank password.
Upvotes: 1