简体   繁体   中英

Can't run rails “db: create” with remote ip on mysql

Here is the log

Can't connect to MySQL server on 'remote.ip.here.lol' (110)
Couldn't create 'solicit' database. Please check your configuration.
rails aborted!
Mysql2::Error: Can't connect to MySQL server on 'remote.ip.here.lol' (110)
bin/rails:4:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)

my db.yml is like this:

default: &default
  adapter: mysql2
  encoding: utf8
  database: db
  host: remote.ip.here.lol
  port: 3306
  username: admin
  password: supressed
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default

test:
  <<: *default

I don't have any clue of how to start, I recently got hired, my boss told about a gem dotenv-rails but I can't see how it fit to the current issue that I'm curently facing.

Edit: apparently using localhost and local database and user works fine, but not with the remote configuration.

Edit 2: I've created environment variables with dotenv and apparently I only need to fill a.env file with the needed information, it worked.

You might not have MySQL running on your machine? It seems you are trying to connect to your server but MySQL is not up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM