2012-07-08 3 views
0

나는 기본적인 RoR 앱을 설정하고있다. 내 모든 데이터베이스는 MySQL과 로컬, 내 데이터베이스, yml 파일이 포함되어 있습니다. 기본보기에 액세스하려고하지만 여전히 ActiveRecord :: ConnectionNotEstablished 오류가 발생합니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 보석 파일루비 온 레일스 ActiveRecord :: ConnectionNotEstablished

# 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 :

gem 'mysql2', '~>0.3.10' 

그래서 이동이 입력 할 때 http://localhost:3000/controller/view를 내가 얻을 : 액티브 :: ConnectionNotEstablished

다른 내가 그 도움이 될 것입니다 포함 할 수 있습니다?

미리 감사드립니다.

+0

당신은 로컬 호스트와 127.0.0.1를 교체하는 경우 그 일을합니까? 또한 Rails 버전은 무엇입니까? 3.2.6? – ScottJShea

+0

127.0.0.1을 localhost로 바꾸면 rake db : migrate를 실행하려고하면 소켓 오류가 발생합니다. 127.0.0.1 rake db : migrate가 오류없이 실행됩니다. 또한, 난 레일에 3.2.2입니다. 감사. – analyticsPierce

+0

당신은 아파치와 MySQL을 설치 했습니까? 결과는 http : // localhost / – chaitanya

답변

1

/etc/mysql/my.cnf을보고 mysql 데몬의 바인딩 주소를 확인하십시오. 그것은 아마도 어떤 IP에 바인딩하지 않습니다. 그렇다면 유닉스 소켓을 사용하는 것이 더 빠르며 그 다음에는 IP 연결이됩니다. ...

바인드 주소의 옵션 이름은 어떤 주소와도 일치하지 않으면 bind-address입니다. 또한 유닉스 소켓에 대한 경로를 지정하는 socket을 찾으십시오. 당신은이 같은 소켓을 사용할 수 있습니다, 당신을 위해 무엇을해야 database.yml

development: 
    adapter: mysql2 
    encoding: utf8 
    database: *****_dev 
    username: **** 
    password: ***** 
    socket: /path/to/the/socket/mysql.sock 

...

관련 문제