programing

mysql2 및 rails3 (번 들러)의 RuntimeError

nasanasas 2020. 10. 16. 07:31
반응형

mysql2 및 rails3 (번 들러)의 RuntimeError


이 오류가 발생합니다.

`establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)
  from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-

여기 에 전체 오류와 내 구성 및 gemfile의 덤프가 있습니다.


Ubuntu 11.10에서 12.04로 업그레이드 한 후에도 동일한 오류가 발생했습니다. 이것이 내가 문제를 해결 한 방법입니다.

gem uninstall mysql2
bundle

여기서 핵심은 '네이티브 확장'이라고 생각합니다. 마지막으로 설치했을 때 다른 버전의 mysql을 사용하고 있었던 것 같습니다.

Installing mysql2 (0.3.11) with native extensions

레일 3.0.7 및 mysql2 0.3.2를 사용하는 동안 동일한 오류가 발생했습니다. 내가 찾은 솔루션, 여기가 , mysql2의 이전 버전을 사용하는 것입니다. 따라서 gemfile을 다음과 같이 편집하십시오.

gem 'mysql2', '< 0.3'

그리고 실행

bundle install 

또한에서 변경 어댑터를 필요 mysqlmysql2여기에 말했듯이 database.yml을에서 RVM와 레일 3 스노우 레오파드 (Snow Leopard)에 mysql2 보석을 설치

에서:

development: adapter: mysql

에:

development: adapter: mysql2


이전 mysql gem 대신 gemfile에 mysql2 gem을 포함하고 나중에 bundle install을 실행 했습니까?


rvm을 사용 중이고 rvm 외부에 mysql2를 추가 한 경우 다음 단계를 시도하십시오. Gemfile에 다음 내용이 있는지 확인하십시오.

gem 'mysql2'

또는 Rails2.x의 경우 :

gem 'mysql2', '~> 0.2.11'

그때:

$ cd RAILS_ROOT
$ gem uninstall mysql2

Select gem to uninstall:
 1. mysql2-0.2.11
 2. mysql2-0.3.6
 3. All versions
> 3 # select "All versions"
$ rvm gemset install mysql2
$ bundle install

이제 레일이 제대로 시작됩니다.


이것은 또한 내가 가진 문제를 해결했습니다.

Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter)

실제로 실행해야합니다 : gem install mysql2 및 gem을 설정에 추가합니다.


"gem install mysql"을 실행하여 gemfile에 동일한 내용을 추가하고 번들을 실행하십시오. 일했다


Windows에서 레일 3을 사용하여 mysql2 gem을 설치하는 데 여전히 문제가있는 사람이 있으면 자세한 설치 단계를 참조하십시오.

http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html


저는 Ruby, Rails, Linux의 초보자입니다. 따라서이 솔루션이 작동하지 않으면 책임을지지 않습니다. :)

1 단계:

sudo gem uninstall mysql2

2 단계:

sudo gem install mysql -v 0.2.7

Start webrick, if the same problem still appears reinstall rails.

This solution works for me.


Same issue for me too. Upgraded to Rails 3.1.rc4 then downgraded to 3.0.3. Worked for me.


as of 0.3.0, and ActiveRecord 3.1 - the ActiveRecord adapter has been pulled out of this gem and into ActiveRecord itself. If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile

the missing file (no such file to load) can be found in the pre 0.3.0 versions of mysql2.

quoted from the documentation of mysql2

참고URL : https://stackoverflow.com/questions/3467054/runtimeerror-with-mysql2-and-rails3-bundler

반응형