nice to meet you all. It is kyon who finally solved the problem today and gave a scream. I will post it for the first time as a memorandum. Thank you very much.
CentOS Linux release 8.1.1911 (Core) mysql Ver 8.0.17 for Linux on x86_64 (Source distribution) Visual Studio Code version: 1.43.1
As you can see in the title, I want to use direnv on linux, so please refer to the URL below. Reference URL Use direnv on Linux I was able to create an .envrc file and pass the path to the Rails project's / bin directory, but I've been fighting this guy ever since.
Access denied for user 'ENV['MYSQL_DATABASE']'@'localhost' (using password: YES)
I think I fought for about a week. I knew that I should write the password directly in database.yml if I looked it up, but after thinking about the future, I decided to use direnv. But I just don't understand. ..
..envrc
export 'DATABASE_USERNAME'="root"
export 'DATABASE_PASSWORD'="password"← mysql password
。。。。。?
database.yml
default: &default
adapter: mysql2
encoding: utf8mb4
username: ENV['DATABASE_USERNAME']
password: ENV['DATABASE_PASSW0RD']
。。。。。。。。??
However, as I looked it up, I thought that the .envrc file would fit, and I wasn't sure how to write the username and password in database.yml.
Suddenly various ways to manage database.yml It means that we arrived at this URL and solved the problem.
database.in yml<%= ... %>You can embed Ruby code with.
And I wrote database.yml as follows.
database.yml
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
You didn't embed it. It's embarrassing.
It's a bad sentence, but thank you for reading to the end. I would like to take this opportunity to post. It was kyon.
Recommended Posts