HEROKU connect to mysql database

Asked

Viewed 2,041 times

2

I’m doing reverse engineering on a system, and what I want is to use the same database as the old system. But I am not able to connect the system database in production with this base. And because it is in MYSQL I am using the gem mysql2, as follows:

heroku config:set DATABASE_URL="mysql2://meuusuariodobaco:minhasenha@link_para_o_banco_de_dados?reconnect=true"

And with that my application is giving the following log:

2016-10-11T19:57:47.792510+00:00 heroku[router]: at=error code=H12 
desc="Request timeout" method=GET path="/" host=bsbmusical.herokuapp.com 
request_id=0fafefe8-3bfa-455c-b693-46ea7f0d3abf fwd="189.6.126.19" 
dyno=web.1 connect=1ms service=30001ms status=503 bytes=0

Detail: the password has a special character *(asterisk), this may be the cause?

I tried to connect in the hand too, but I couldn’t:

production:
  <<: *default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: meuUsuario
  password: minhaSenha
  host: meuHost
  port: portaDoBanco
  • Why do you think this error has to do with the bank? It seems to me a problem when getting the Asset favicon.ico

  • It’s been at the bank anyway. I did a test with the mysql2 gem, running on the Heroku console according to the documentation (https://github.com/brianmario/mysql2), and it has given the same error. I don’t know what it might be, because when I run Rails locally connected on that basis it will, but when I try in production it won’t.

1 answer

1

Mysql in Heroku is generated by an add-on, you will need to add it to your app in Heroku and follow the setup steps - https://elements.heroku.com/addons/cleardb

Something like:

# add cleardb add-ons to your app
$ heroku addons:add cleardb:ignite

# set CLEARDB_DATABASE_URL
$ heroku config:set DATABASE_URL='mysql://meuusuariodobaco:minhasenha@link_para_o_banco_de_dados?reconnect=true'

$ heroku config:set CLEARDB_DATABASE_URL='mysql://meuusuariodobaco:minhasenha@link_para_o_banco_de_dados?reconnect=true'
  • Clear DB not only works with their bank?

  • I tested it and it’s still the same mistake

  • Just that mistake or is there more? Put it there so we can try to figure out what’s going on. Another solution would be to migrate the data to Postgres so it is much easier, since Heroku uses by default.

  • It’s just that mistake

Browser other questions tagged

You are not signed in. Login or sign up in order to post.