programing

잘못된 mysql 클라이언트 라이브러리 용으로 컴파일 된 mysql2 gem

nasanasas 2020. 11. 19. 21:36
반응형

잘못된 mysql 클라이언트 라이브러리 용으로 컴파일 된 mysql2 gem


레일스 애플리케이션을 통해 mysql 서버에 연결하려고하면 다음과 같은 오류가 발생합니다.

D:/Program_Files/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 
Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.0.27. (RuntimeError)

어떻게 수정할 수 있습니까?


나는 당신과 같은 문제가 있었거나 적어도 증상이 같았습니다.

배경 : 저는 Windows 컴퓨터에 로컬로 설치된 Rails 3, mysql2 gem 및 MySQL 커뮤니티 서버 버전 5.5.21 (32 비트)을 사용하고있었습니다. libmysql.dllMySQL 설치에서 클라이언트 라이브러리 ( )를 가져 와서 Ruby 설치 bin폴더에 복사했습니다 .

을 실행했을 때 bundle exec rake db:create귀하와 동일한 오류 메시지가 표시되었으며 "최신 MySQL 릴리스에서 클라이언트 라이브러리를 가져 왔을 때 어떻게 클라이언트 라이브러리를 구식으로 만들 수 있습니까?"라고 생각했습니다.

을 (를) 할 때 표시되는 유용한 메시지가 있습니다 gem install mysql2. 불행히도 Bundler와 함께 gem을 설치하면 Bundler가 메시지를 먹습니다. 여기있어:

=========================================================================
You've installed the binary version of mysql2. It was built using MySQL 
Connector/C version 6.0.2. It's recommended to use the exact same version
to avoid potential issues.

At the time of building this gem, the necessary DLL files where available
in the following download:

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

And put lib\libmysql.dll file in your Ruby bin directory, for example
C:\Ruby\bin

이 지침에 따라 문제가 해결되었습니다.

참조 링크


gem을 제거하고 다시 설치하면 파일을 직접 다운로드하고 이동할 필요없이이 문제가 해결되는 경우가 많습니다. Rails 앱 디렉토리에서 :

> gem uninstall mysql2

You have requested to uninstall the gem:
    mysql2-0.3.11
database_cleaner-0.9.1 depends on [mysql2 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled mysql2-0.3.11

> bundle install

Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Using rake (0.9.2)
Using i18n (0.6.1)
... <SNIP> ...
Installing mysql2 (0.3.11) with native extensions
... <SNIP> ...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

64 비트 버전의 mysql과 32 비트 버전의 루비를 사용하는 경우 http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using 에서이 솔루션을 확인하십시오. -루비 위드 잇 /

기본적으로 mysql 웹 사이트에서 단일 커넥터를 다운로드하고 다운로드 한 커넥터로 mysql 또는 mysql2를 컴파일해야합니다.

Ruby 1.9.2의 경우 :

gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

Ruby 1.9.3 용 : (mysql2 변형 표시)

gem pristine mysql2 -- --with-mysql-config=C:\mysql-connector-c-noinstall-6.0.2-win32    

Note the use of forward slashes for the directory where MySQL Connector/C was extracted.


I had an issue just like this:

Incorrect MySQL client library version! This gem was compiled for 5.5.29 but the client library is 5.6.17.

The issue for me was that I had both versions, 5.5.29 and 5.6.17, installed on my machine. I have no idea how. When I bundled it automatically chose the 5.5.29 version. I uninstalled that one and then reinstalled my gem and that fixed the issue.


I discovered a completely different cause for this problem. I had been using the mysql gem. I built the mysql2 gem but I forgot to update my database.yml. With the mysql2 gem, it needs to say:

  development:
    adapter: mysql2

rather than

  development:
    adapter: mysql

The gem built, but I got the error when I next ran rake.

Obvious once you've seen it, but you get the same error message as discussed here!

By the way, the command to build the mysql2 gem on my machine was a bit more complicated than described above:

gem install mysql2 -- --with-mysql-lib="c:\mysql-connector-c-noinstall-6.0.2-win32\lib"  --with-mysql-include="c:\mysql-connector-c-noinstall-6.0.2-win32\include" --with-mysql-dir="c:\mysql-connector-c-noinstall-6.0.2-win32"

To Add to the existing answer. ( windows platform specifically )

Ruby really sucks on top of this. Rails should not actually care about the version of the connector or the mysql version. -- but that's my opinion.

In order to get this **ing thing working, you need 2 things. mysql2 gem and libmysql.dll and you need to match them up in terms of the version. (this caused confusion for me, because I can see the latest connector is 6.x while mysql is only 5.x, how should I match them up)

mysql2 gem. and when you install it you need to specify the connector.

     gem install mysql2 --platform=ruby -- 
     --with-mysql-lib="d:\mysql\lib" --with-mysql-include="d:\mysql\include"

it does not need to be connector downloaded from oracle. all you need is a mysql installation and the lib include folder underneath it. then put the libmysql.dll under railsinstaller bin folder.

if it didn't work to make you install mysql2 gem succesfully => for my case it is because my mysql is too old (why would ruby care that). so I get some latest mysql from oracle. use the lib include libmysql.dll under it. you don't really need to upgrade your database, you can keep it somewhere and continue to use it after you generated the 2 required components

my case: I use a very ancient mysql database and I am unwilling to upgrade it at the moment. so I back that database up and restored it later


in my case on windows, incorrectly copied libmysql.dll from MySQL Server 5.5 directory to ruby200/bin. correct is to copy libmysql.dll from mysql-connector-c-noinstall-6.0.2-win32.


I had the same problem , and I have solved the follows:

1 :: Download the zip the following link: https://dev.mysql.com/downloads/connector/c/

2 :: decompress the file ( libmysql.dll ) in the " Provider" folder of project.

3 :: Volve one to run the command bundle install

and ready , solved !

https://dev.mysql.com/downloads/connector/c/

참고URL : https://stackoverflow.com/questions/8740868/mysql2-gem-compiled-for-wrong-mysql-client-library

반응형