How can I get rake db:migrate to decrypt the encrypted database password created by the secure_yaml gem?
I am using the secure_yaml gem to encrypt the password of my database stored in the database.yml.
The YAML file looks something like this after encryption:
development:
adapter: oracle_enhanced
database: db_name
username: username
password: ENC(yCuO9BOKb3pa2SoiFq+B6A==)
I try using the task rake db:migrate to migrate the db, but for some reason, the rake task can't decrypt the secure_yaml encryption.
I end up getting the error:
ORA-01017 Invalid Username/Password
And I guess the reason is because the rake task reads the encrypted database password as a plain string.
If its not possible,
what is a better way to encrypt the database password in the YAML file?
Related
I have installed postgres via brew. However, after running rake db:create I get error
role 'posgres' does not exist
I can not run psql as role of my user does not exist, which is logical, but I can not login with -u postgres either.
Any suggestions, how to create postgres user ?
It seems like the service is not running / turned on after instal.
Documentation reference:
https://www.postgresql.org/docs/current/static/server-start.html
Then perform initdb /[data location]
Then you will need to sudo to postgres user (the service user) to issue commands to the database.
I'm in an environment with authentication tokens, so typically a SSH password is not required. My serverspec tests are always asking me for a password. Is there a way to prevent this?
No password required:
$ ssh atlspf01
newatson#atlspf01:~$
Yet, in serverspec
$ rake spec
Password:
Relevant code in spec_helper.rb
require 'serverspec'
require 'net/ssh'
set :backend, :ssh
...
set :host, ENV['TARGET_HOST']
set :ssh_options, :user => ENV['USERNAME']
UPDATE: Problem is that net::ssh does not support Kerberos authentication (gssapi-with-mic). Use ssh::ssh::kerberos or use ssh keys.
On your configuration, you only pass info about user to ssh_options
Assuming that your target host is stored into environmental variable TARGET_HOST and username is stored into USERNAME, you should do something like this:
set :ssh_options, Net::SSH::Config.for(ENV['TARGET_HOST']).merge(user: ENV['USERNAME'])
I have a website already hosted on heroku.I added all content in the remote refinery.now i hosted the same website on apache using passenger.And i want to copy the content from the heroku refinery to the apache one.How do i go about it?
my database.yml file is as follows:
development:
adapter: mysql2
encoding: utf8
database: app_development
pool: 5
username: root
password: root
test:
adapter: mysql2
encoding: utf8
database: app_test
pool: 5
username: root
password: root
production:
adapter: mysql2
encoding: utf8
database: app_production
pool: 5
username: root
password: root
Im using ubuntu 13.10
Is this your new database.yml file? or were you using mysql on heroku too (most people use postgres)?
working on the assumption that you were on postgres on heroku and want to move to a mysql local database you will first need to copy your database information onto your new server.
For information on how to get the data off've your heroku database see here and here, the relevant line is here:
$ PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump
Now you'll have a postgres backup file that will be all the sql commands needed to recreate the backup with all your data, you would think that since sql is a standard and mysql uses that too you could just do
mysql my_new_database_name < mydb.dump
Unluckily you're often not that lucky (I would recommend trying it, you never know with simple enough database structures) and you will then need to use a converter, this question recommends using pg2mysql.
This does of course bring up the question of why you want to move to a mysql installation?
Here is an article by digital ocean comparing sqlite, mysql and postgres, which has this to say about postgres.
PostgreSQL is the advanced, open-source [object]-relational database
management system which has the main goal of being standards-compliant
and extensible. PostgreSQL, or Postgres, tries to adopt the ANSI/ISO
SQL standards together with the revisions.
For my own opinion I quite like postgresql and find it has less unpleasant surprises than mysql but YMMV. Given the extra work in switching databases I'd probably be inclined to stick to Postgres but that's my opinion.
I restarted my computer recently and after trying to start my db locally with rails s I got the following:
/Users/example_name/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in
`initialize': could not connect to server:
No such file or directory (PGError)
Then I tried to manually start the db by writing:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
And then it said server starting So I retyped rails s and then I recieved the error:
FATAL: role example_name doesn't exist
Which was a strange error I never got before so I tried to create the role again and after running rails s again I then got:
FATAL: database "example_db" does not exist (PGError)
I don't think I did anything to drop the db so I'm unsure what exactly is going on.
I did rake db:create:all and bundle exec rake db:migrate and now it works but the DB is empty! how did this happen? this isn't going to empty my production db if I deploy will it?
In a VPS I have Postgres installed and 2 Rails projects. Both are running on production mode and connecting PG as different users.
Now I want to set CruiseControl.rb for one of them. Everything went perfectly, except when cruise is trying to run the test it's throwing this error:
PGError: ERROR: permission denied to create database
: CREATE DATABASE "myProject" ENCODING = 'utf8'
This test database is created with a different owner name, and all of them are specified correctly in ~/.cruise/projects/myProject/work/config/database.yml.
When I am running these following series of commands manually inside ~/.cruise/projects/myProject/work, they are working perfectly.
RAILS_ENV=test rake db:migrate
rake test
I've created the database using these following commands:
create user test_user with password 'abcxyz';
create database test_database TEMPLATE template0 owner test_user;
grant all privileges on database test_database to test_user;
After hitting the Build Now button, the test_database is getting deleted, and then its trying to create it again and throwing that exception.
I'm puzzled, why the test db is getting deleted on the first place? Is there anything I'm missing here?
It sounds like you haven't granted access to your test user to create a new database, even though you issued permissions for the test_user on the existing test_database.
You may need to grant privileges to create a new DB like so:
GRANT CREATE ON SCHEMA public TO test_user;
The commands you executed before created the test_user and so must have been executed as an admin or the postgres user.
TL;DR
You should compare the permissions for your cruise user to the user you executed these steps with manually, something is wrong preventing the test db creation during db:test:prepare