This error occurs when creating rails db:create when building rails environment with AWScloud 9.
I would appreciate it if you could tell me how to solve this problem.
error code
ec2-user:~/environment/RailsReactApp(master)$railsdb:create
/home/ec2-user/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.7/lib/active_record/database_configurations.rb:234:in `build_db_config_from_string': '{ socket => /var/lib/mysql/mysql.sock }' is not a valid configuration. Expected '/var/lib/mysql/mysql.sock' to be a URL string or a Hash. (ActiveRecord::DatabaseConfigurations::InvalidConfigurationError)
database.yml
default:&default
adapter —mysql2
encoding —utf8mb4
pool:<%=ENV.fetch("RAILS_MAX_THREADS"){5}%>
username —root
password:
socket: /var/lib/mysql/mysql.sock
development:
<<:* default
database —RailsReactApp_development
test:
<<:* default
database —RailsReactApp_test
production:
<<:* default
database —RailsReactApp_production
username —RailsReactApp
password:<%=ENV['RAILSREACTAPP_DATABASE_PASSWORD']%>
When this error occurs, the config/database.yml is often written incorrectly.
socket:/var/lib/mysql/mysql.sock
↑ This line is probably incorrect.If you follow the question, the first indent is a full-width space and not two half-width spaces.Therefore, I suspect that it is not loaded as the correct YAML.
© 2024 OneMinuteCode. All rights reserved.