Trying to run a rails app in prod on Ubuntu 16.04 and installed mysql Ver 14.14 Distrib 5.7.24
, Ruby 2.5.3
, and using the mysql2
gem. It works fine on my Mac 10.13. My Rails app can't seem to read the DB name in Ubuntu.
Can't find the DB name: {:adapter=>"mysql2", :encoding=>"utf8", :database=>nil, :username=>"myUser", :password=>"secret", :host=>"127.0.0.1", :port=>3306}
Then adds 127.0.0.1 as the DB name: {:adapter=>"mysql2", :encoding=>"utf8", :database=>"127.0.0.1", :username=>"myUser", :password=>"secret", :host=>"127.0.0.1", :port=>3306}
My database.yml
production: adapter: mysql2 encoding: utf8 database: mydb username: myUser password: secret host: 127.0.0.1 port: 3306
I've been pulling my hair out as to why I can't connect to the DB in my Ubuntu server. I can log into mysql through the CLI fine with the DB user fine.
I'm also seeing the same issue on an Ubuntu box with Vagrant so thats consistent.
Any help is extremely appreciative at this time.
I have no idea but putting it in this format works. I tried everything else, different DB name, etc to no avail:
production: url: mysql2://user:pass@localhost/myDb
Thank you for your responses.
Your database.yml should look something like this:
development:
adapter: mysql2
encoding: unicode
pool: 5
username: mysql_user
password: your_password
host: localhost_or_your_host
database: db_name
Do change your environment to match your requirements. This will work for your development mode.
\ngem install mysql2 \n
\ndevelopment: \n adapter: mysql2 \n encoding: utf8 \n database: my_db_name \n username: root \n password: my_password \n host: 127.0.0.1 \n port: 3306 \n
\nrake db:create \n
Make your changes by following these steps.This will surely work for your development mode.
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.