Reputation: 3025
I am working on setting up a basic RoR app. All my databases are MySQL and local, my database,yml file is included. I am trying to access a basic view but am still getting the ActiveRecord::ConnectionNotEstablished error. What am I doing wrong?
# database.yml
development:
adapter: mysql2
encoding: utf8
database: *****_dev
username: ****
password: *****
host: 127.0.0.1
port: 3306
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
database: *****_test
username: ****
password: *****
host: 127.0.0.1
port: 3306
production:
adapter: mysql2
encoding: utf8
database: *****_prod
username: ****
password: *****
host: 127.0.0.1
port: 3306
MySQL2 in the gem file:
gem 'mysql2', '~>0.3.10'
So when go to type in: http://localhost:3000/controller/view
I get: ActiveRecord::ConnectionNotEstablished
What else can I include that would be helpful?
Thanks in advance.
Upvotes: 0
Views: 1368
Reputation: 8954
Have a look at your /etc/mysql/my.cnf
and check for the binding address of the mysql deamon. It probably doesnt bind to any ip. Then it will use unix sockets which are by the way faster then ip connections,...
Option name for the bind address is bind-address
if theres no match it wont bind to any address. Also have a look for socket
which specifies the path to the unix socket. You can use the socket like this in your database.yml
development:
adapter: mysql2
encoding: utf8
database: *****_dev
username: ****
password: *****
socket: /path/to/the/socket/mysql.sock
That should do it for you,...
Upvotes: 1