I got this error “ActiveRecord::ConnectionNotEstablished” while using Ruby on Rails with MYSQL initially. The error means that the Rails framework is not able to connect to MYSQL server. The problem is that the root(MYSQL) user was not able to connect to MYSQL through Rails. So to solve this issue, login as root in MSQL and create a new MYSQL user and config Rails to use the new MYSQL user and password.
Create User MYSQL Command:
Grant Access to Required Database to the New User:
Note: The first * represents the database and second * represents the table name. *.* means that user is given access to all databases and its table. You can also give restricted access to a specific database by replacing *.* by database_name.*
Now use the new MYSQL user in config/database.yml file which solves the issue.
- Gem v1.8
- Ruby v1.9
- Rails v4.0.3
- MYSQL Server v5.5
- mysql2 gem in Rails
- Rails default web server (WEBrick)