find rails database

  1. Open a terminal window.

  2. Navigate to your Rails application's root directory using the 'cd' command.

  3. Access the Rails console by running the 'rails console' command.

  4. To find the database configuration, use the following command: ruby Rails.application.config.database_configuration

  5. The output will be a hash containing database configuration details such as adapter, database name, username, and password.

  6. To specifically access the database connection configuration for the current environment (e.g., development, test, production), use: ruby Rails.application.config.database_configuration[Rails.env]

  7. View the database connection details, including adapter, database name, username, and password, in the hash returned by the command.

  8. To retrieve the active connection pool for the current environment, use: ruby ActiveRecord::Base.connection_pool.db_config.configuration

  9. Examine the hash output for connection pool details, including the adapter, database name, username, and password.

  10. Exit the Rails console when done by typing 'exit' or pressing Ctrl + D.

  11. Close the terminal window.