I will write a summary of the solution for latecomers about the solution when an error occurs when executing rails db: create.
windows 10 home ubuntu 20.04 LTS ruby 2.7.1 Rails 6.0.3 postgresql 11
$ rails db:create
FATAL: role "admin0" does not exist
Couldn't create 'taskleaf2_development' database. Please check your configuration.
rails aborted!
PG::ConnectionBad: FATAL: role "admin0" does not exist
/home/admin0/taskleaf2/bin/rails:9:in `<top (required)>'
/home/admin0/taskleaf2/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
Is the key point this time around the 5th line from the top?
I had encountered a similar error before and had already resolved it, so I tried the same method. https://teratail.com/questions/297341
$ yarn install
However, even this could not be solved.
Notice that the error is PG :: ConnectionBad :. However, the DB should be running like the following command ...?
$ sudo service postgresql start
[sudo]admin0 password:
* Starting PostgreSQL 11 database server [ OK ]
* Starting PostgreSQL 13 database server [ OK ]
I decided to try starting it by another means (below).
$ sudo su - postgres
\q
When I ran rails db: create
again, the error statement changed.
$ rails db:create
WARNING: could not flush dirty data: Function not implemented
Created database 'taskleaf2_development'
WARNING: could not flush dirty data: Function not implemented
Created database 'taskleaf2_test'
After that, I searched with this error sentence
https://stackoverflow.com/questions/45437824/postgresql-warning-could-not-flush-dirty-data-function-not-implemented
Because this seemed to be influential
Part of the contents of /etc/postgresql/11/main/postgresql.conf
was rewritten as follows
fsync = off
data_sync_retry = true
Try running rails db: create
again
rails db:create
Database 'taskleaf2_development' already exists
Database 'taskleaf2_test' already exists
Apparently it was successful. Since the server was able to start, it is judged that this solved the problem this time.
Recommended Posts