mysql - Win7x64、Ruby 2.0、MySQL 5.6 上的 gem mysql2 段错误

标签 mysql ruby-on-rails windows rubygems

当我使用最新版本时,Rails 4 崩溃:MySQL-5.6.13 与 mysql-connector-c-6.1.1-winx64 一起。

C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2/mysql2.so: [BUG] 段错误 ruby​​ 2.0.0p195 (2013-05-14) [x64-mingw32]

正如我所学到的

...mysql2/mysql2.so: [BUG] Segmentation fault ruby 2.0.0p247

即使使用 win32,也没有补救措施。 那么,我应该回滚到 Rails3 和/或 Ruby 1.9 吗?

最佳答案

MySQL Connector/C 64 位中包含的 libmysql.lib 与 mingw64-gcc 编译器不兼容。

您需要生成mingw64兼容的libmysql.lib文件。

要生成libmysql.lib文件,需要gendef.exe,它可以从mingw-w64发行版中获取(我是从 https://code.google.com/p/structure-svm-map/downloads/detail?name=svm-map-win.zip&can=2&q= 获取的)

在mysql连接器的lib文件夹中,按照以下步骤生成libmysql.lib。

gendef.exe libmysql.dll

dlltool -v --dllname libmysql.dll --def libmysql.def --output-lib libmysql.lib

并运行正常的 gem install 命令。 gem install mysql2 -v '0.3.12b6' -- --with-opt-dir="..."

注意:对于 MySQL Connector/C 6.1,由于版本比较例程,您无法使用 mysql2 模块,但有以下异常(exception)。 RuntimeError:MySQL 客户端库版本不正确!这个 gem 是为 5.7.2-m12 编译的,但客户端库是 6.1.0。

您应该在 http://dev.mysql.com/downloads/connector/c/6.0.html#downloads 中使用 mysql-connector-c-6.0.2-winx64.msi

来源:https://bugs.ruby-lang.org/issues/8591

关于mysql - Win7x64、Ruby 2.0、MySQL 5.6 上的 gem mysql2 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18738890/

相关文章:

c# - 带定时器的 Windows 服务

mysql - SQL 错误 : 1064 Hibernate

mysql - HIbernate 批量插入或更新在 Spring Boot 中不起作用

MySql 通用查询日志

ruby-on-rails - Rails 4/postgresql - 根据另一个表数据在一个表上插入数据(after_create)

windows - 如何从提升的 PowerShell 控制台以非管理员身份运行进程?

windows - 创建开发人员许可证后,我可以更改用于 Visual Studio 的 Microsoft 帐户吗?

php - 太多行导致 500 错误?

ruby-on-rails - RnR : Long running query, Heroku 超时 : webhooks? Ajax?

html - For Each in rails html模式延续