permission denied for relation schema_migrations - ruby-on-rails

I'm getting this error when I run rake db:migrate:
permission denied for relation schema_migrations
This is what I have in my database.yml file:
development:
adapter: postgresql
encoding: unicode
database: enpoweredapp_development
pool: 5
username: enpowered
password: enpowered
host: localhost

Related

setting up a postgresql database

I am getting the error below when I try creating a database. Here is the database.yml:
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
adapter: postgresql
encoding: unicode
database: MyDatabase
host: localhost
pool: 5
username: name
password: name`
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test. postgresql
production:
adapter: postgresql
encoding: unicode
database: MyDatabase_Production
host: localhost
pool: 5
username: name
password: name
role: MyRole
Here is the error:
Database 'MyDatabase' already exists
PG::SyntaxError: ERROR: syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"." postgresql" ENCODING = 'utf8'
^
Couldn't create 'db/test. postgresql' database. Please check your configuration.
rails aborted!
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"." postgresql" ENCODING = 'utf8'
^
Caused by:
PG::SyntaxError: ERROR: syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"." postgresql" ENCODING = 'utf8'
^
Tasks: TOP => db:create
(See full trace by running task with --trace)
I am getting the error above when I run rails db:create up my posgresql database
It looks like maybe some of your text config got deleted. Should be something like:
test:
<<: *default
database: test
username: name
password: name
There is a syntax error in database configuration as stated in the error
<<: *default
database: db/test. postgresql
There is a dot and blank space that are not allowed. Renaming it to something else will solve the problem.
Example:
<<: *default
database: db/test_postgresql

rake db:create password authentication fails for user

While running the command rake db:create, the system throws postgresql authentication fails
FATAL: password authentication failed for user "postgres"
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "username"=>"postgres", "password"=>"password", "timeout"=>5000, "host"=>"localhost", "database"=>"rails-sample-guestbook-master_development"}
rake aborted!
database.yml file
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: supranimbus
password: 123456789
timeout: 5000
host: localhost
development:
<<: *default
database: rails-sample-guestbook-master_development
test:
<<: *default
database: rails-sample-guestbook-master_test
production:
<<: *default
database: rails-sample-guestbook-master_production
I guess the problem is setup password on postgresql if you don't remember the default password then go to pgAdmin click to open dashboard and then the left sidebar see the below image
Click the Properties... then will open a modal like see the below image
and click the Definition tab and see the Password field and set the new password, remember this password for postgres username.
That's is for password setup!
Now update your database.yml file like below
default: &default
adapter: postgresql
encoding: unicode
username: postgres
password: 123456 #=> which you set for postgres
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: project_development
Hope to help

How to connect to Postgresql from Ruby On Rails App

I am new in Ruby on rails and i am using ruby v 1.9.3 & rails 3.2.12 with window 7
i want to PostgreSQL database connection in my app.
this is my db connection
development:
adapter: postgresql
encoding: unicode
database: mmagap_development
pool: 5
timeout: 5000
host: 127.0.0.1
username: postgres
password: root
test:
adapter: postgresql
encoding: unicode
database: mmagap_test
pool: 5
username: postgres
password: root
production:
adapter: postgresql
host: 127.0.0.1
encoding: unicode
database: mmagap_production
pool: 5
username: postgres
password: root
this connection every time give error
D:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in
`initialize': received invalid response to SSL negotiation: - (PG::ConnectionBad)
Please help how to create PostgreSQL database connection in my RoR app.
You can change host: 127.0.0.1 to host: localhost. It should solve the issue.
First install pg gem
gem install pg
your apps database.yml file shoud be like this
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password: password1
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp
password: password1
Now run
rake db:setup
rake db:migrate
and after this run
rails s
Use this link to verify, Is Postgresql installed successfully or not.
DigitalOceanCommunityArticle Click Here
AskUbuntuLink Click Here
Removed host from development config in database.yml,its worked for me.
development:
adapter: postgresql
database: tes
pool: 5
timeout: 5000
username: postgres
password: root
First you should install PostgreSQL and PgAdmin
After installing this thing you will have to add some pic of code ( to connect PostgreSQL to your rails project ) in your project config/database.yml file (before add PostgreSQL code you will have to remove all Sqlite3 code from config/database.yml file).
development:
adapter: postgresql
encoding: unicode
database: database_name
pool: 5
host: localhost
username: your_PostgreSQL_username
password: your_PostgreSQL_password
test:
adapter: postgresql
encoding: unicode
database: database_name
pool: 5
username: your_PostgreSQL_username
password: your_PostgreSQL_password
staging:
url: <%= ENV['DATABASE_URL'] %>
production:
url: <%= ENV['DATABASE_URL'] %>
postgres is default username and password in PostgreSQL database\
after add this pic of code you have to add one line of code in your rails project root directory in Gemfile
gem ‘pg’
and you must have to remove sqlite3 code from Gemfile ( gem 'sqlite3', '~> 1.4' )before adding gem 'pg'

Can't rake db:migrate

When I'm trying to migrate my database I get an error Mysql2::Error: Table 'database.lorem_ipsum' doesn't exist: SHOW FULL FIELDS FROM ``lorem_ipsum. I've created database before by rake db:migrate
config/database.yml
development:
adapter: mysql2
database: database
username: root
password:
Can you try this ?
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: database
pool: 5
username: root
password:
On your database.yml

Username and password in database.yml file ignored if not root

I'm attempting to run a RoR app and it seems to be ignoring my username and password if it isn't root, any thoughts?
If it is configured as below, it works:
development:
adapter: mysql2
database: dbname
user: root
password: root_password
pool: 5
timeout: 5000
However, if it is set up with a non root user, it fails with the message `connect': Access denied for user 'root'#'localhost' (using password: YES) (Mysql2::Error)
development:
adapter: mysql2
database: dbname
user: username
password: username_password
pool: 5
timeout: 5000
mysql -uusername -p<username password> <dbname> connects without any issue. Specifying a host or hostname doesn't fix it.
Update
database.yml
development:
adapter: mysql2
database: dbname
user: root
# username
password: root_password
# username_password
pool: 5
timeout: 5000
production:
adapter: mysql2
database: dbname
user: username
password: username_password
pool: 5
timeout: 5000
results of running RAILS_ENV=development bundle exec rails c
Loading development environment (Rails 3.2.11)
irb(main):001:0>
My database.yml was out dated(set up incorrectly). user is not the correct key, it is username.
development:
adapter: mysql2
database: dbname
username: root
# username
password: root_password
# username_password
pool: 5
timeout: 5000
production:
adapter: mysql2
database: dbname
username: username
password: username_password
pool: 5
timeout: 5000

Resources