Unable to access external database from Heroku App - ruby-on-rails-3

I have rails 3.2.13 application running on heroku. I want my application to access a remote MySQL database. For that I have changed the DATABASE_URL in heroku config. Here is how I did it
heroku config:add DATABASE_URL=mysql2://user_name:password#171.121.123.120:3306/database_name
Above command changes the database_url successfully.
But when I try to run heroku run rake db:migrate it errors out. Below is the error I get
Connecting to database specified by DATABASE_URL
rake aborted!
Access denied for user 'user_name'#'ec2-23-20-128-131.compute-1.amazonaws.com' (using password: YES)
/app/vendor/bundle/ruby/2.0.0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
I have added wild card like %.%.%.% at my MySQL server to allow any IP to access database but even that is not working. I have able to access database from my local dev machine after adding those wild cards.
Thanks

Do you have your credentials defined in /app/vendor/bundle/ruby/2.0.0/gems/mysql2-0.3.11/lib/mysql2/client.rb ? It looks like the migrate command is trying to pull the info from that file.
EDIT: sorry, the code block you had got cutoff on my screen. Does everything look right in the client.rb file?

Related

Installing RCU for Oracle Data integrator runs on Error

I am trying to installing RCU for Oracle Repository Creation utility however everytime I try to install the development repository it runs on error.
Steps to reproduce the issue.
I run rcu bat file
Create repository/system load and product load
3.Choose oracle as database type/hostname localhost, port 1521 servicename xe, username sys and the password (I am able to login into oracle database with this login information) (I am using oracle 18c express
I am using the prefix dev
I am adding password for schemas, supervisor, and for the repository user.
I am not touching the tablespaces
I start the install and several error messages are dropping. like
Ora-65096 invalid common user or role name
Ora-01917 DEV_STB user does not exists
Ora-00955 The name has already been in use by another object.
My question what could be the problem with the installation of RCU and How can I resolve the issue ?
Funny thing is I am trying to install odi and RCU based on step by step video still something went wrong...
The issue here is you are logging to CDB with the service name XE. You need to log into the PDB (Plugable database).
Just change the service name from XE to XEPDB1 while connecting to the DB through RCU and your issue should be resolved.

How to deploy with Capistrano, restarting unicorn service without sudo and without a root SSH connection

I'm new with Capistrano, and after reading documentation I can deploy all app files and service unicorn reload, but I think I could do it better.
The documentation says to create a user without password, but I try to avoid this option.
Now I'm using two users, one is root with an SSH connection (to reload unicorn), but I have read it is a bad practice, and the another is rails default Digitalocean autocreated.
I connect with both via SSH to the server.
In Capistrano files, I have:
production.rb:
set :deploy_to, "/home/rails/www/digitalshelving"
role :web, %w{rails#xx.xxx.xxx.xx}
server "xx.xxx.xxx.xx", user: "rails", roles: %w{web}
And a .rake file (task):
namespace :deploy_ds do
task :reload_unicorn do
on "root#xx.xxx.xxx.xx" do
execute :service, "unicorn reload"
end
end
task :upload_git do
run_locally do
# Git add + commit + push
end
end
end
before "deploy:starting", "deploy_ds:upload_git"
after "deploy:finished", "deploy_ds:reload_unicorn"
I think I should avoid root ssh connections, but then, I can not execute service unicorn reload.
Any comments will be appreciated.
Thanks Tom Lord I managed to do it giving to the user used for deployment the capacity to execute sudo service unicorn reload without password.
Here is explained.
For me, is the best solution in smaller projects with only one developper and Linux administrator, better than creating a user without password as it says Capistrano docs.
Now I can deactivate root access with SSH, as is recommended.
Even though any comment or correction will be more accurate and welcome, due to my lack of linux security knowledge

Redis NOAUTH Authentication required. [tcp://127.0.0.1:6379] Laravel

I am working on a Laravel project that uses dingo package to manage some APIs. I changed CACHE_DRIVER=array variable in my .env file to CACHE_DRIVER=redis because dingo no longer support array for CACHE_DRIVER. I therefore installed redis on my system and included the package in my Laravel project by adding "predis/predis": "~1.0" in my composer.json and updating with the command composer update. Up until now everything works just fine. However, to create database table and seed them using php artisan migrate --seed, I get the error:
[Predis\Connection\ConnectionException]
SELECT failed: NOAUTH Authentication required. [tcp://127.0.0.1:6379]
Note: when I was installing redis, I added a password. I also authenticated using the two commands redis-cli to switch to redis and then AUTH mypassword. Yet when I try to seed, it still throws the same error. Please what am I doing wrong?
Thanks for any help.
I would start with setting redis password in REDIS_PASSWORD environment variable (e.g. in .env file). See https://laravel.com/docs/5.3/redis#configuration for more details about redis configuration in Laravel.
Make sure you are running your redis server when you are seeding.
Run: redis-server

Openfire database settings issue in mac

I have Openfire 3.7.1 installed on my Mac and have XAMPP installed aswell. I am having trouble configuring OpenFire. In the server settings I have given san-imac.local.lan as the domain name. The selected Standard database connection and picked MySql Database Driver. This is the databse URL jdbc:mysql://localhost:3306/test and given the username password of XAMPP phpmyadmin. But it says
A connection to the database could not be made. View the error message by opening the "/logs/error.log" log file, then go back to fix the problem.
First of all there is no such file in the /logs folder. What should I do to get this working and follow the procedures to get OpenFire up and running.
I need to build an app to connect to openfire for IM chatting like Gmail, Facebook, Yahoo using XMPP. If anybody could provide any guidance aswell, it will be very helpful.
Make Sure that your database is setup correctly including the name of your database, database username, and user's password. If you have this correctly configured then your opens ire should work just fine. Note that it will not accept if the database username has an empty password or not enough access rights to the database.
I hope that those hints will solve your problem.
check your password and username, I had the same error and it took me a while to figure out that I had my username wrong.
Resolved the issue.
log file is not getting created due to file write permission. To resolve this run OF server as follows
Run the openfire.sh file from terminal with sudo. This will start the OF with root access Now the error log file will be created.
My log file has error message as access denied to user #localhost. As I kept the user field blank in db connection page of openfire set up.
Keep the user field as root#localhost if u are using localhost.

How to Change Heroku-Postgresql DB password

Simple question but my googling has completely failed me.
How do you change the password for the postgres database for a Heroku Rails application?
heroku pg:credentials DATABASE --reset ought to do it
Source: https://devcenter.heroku.com/articles/heroku-postgresql
pg:credentials --reset is deprecated. Please use pg:credentials:rotate instead
heroku pg:credentials:rotate DATABASE -a sushi
Source: https://devcenter.heroku.com/articles/heroku-postgresql-credentials
This used to not be possible, but now with the new Heroku Postgres plans you can now 'rotate' your database credentials.
You can do this via heroku pg:credentials HEROKU_POSTGRESQL_GRAY_URL --reset where the HEROKU_POSTGRESQL_GRAY_URL is the correct name based on your heroku config output.
On old plans, where this may be unsupported, you may be able to get heroku support to do it if you logged a ticket although they'll probably want a valid reason.