Rails 5和Ruby 2.3.3无法加载libmysql.dll

时间:2017-07-04 18:55:02

标签: mysql ruby-on-rails ruby ruby-on-rails-5 mysql2

在为使用mysql数据库创建的应用程序启动服务器时,在控制台中记录以下错误消息。

Failed to load libmysql.dll from C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems\2.3.0\gems\mysql2-0.4.7-x86-mingw32\vendor\libmysql.dll

环境详情:

Window 7 64 bit
Rails 5.0.4
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
mysqld  Ver 5.7.18 for Win64 on x86_64 (MySQL Community Server (GPL))

从mysql2 ruby​​ gem发布安装消息,在控制台上收到以下消息。

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

At the time of building this gem, the necessary DLL files were retrieved from:
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.10-win32.zip

This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.

我尝试了here的解决方案,但没有效果。

任何帮助表示感谢,提前谢谢。

2 个答案:

答案 0 :(得分:5)

将mysql2 ruby​​gem从版本0.4.7降级到0.3.21解决了我的问题。

接下来的步骤

rails new blog -d mysql # created application with mysql as database
gem uninstall mysql2 #uninstalled mysql2-0.4.7
Gemfile :
    gem 'mysql2', '0.3.21' #Gemfile changed mysql2 version to 0.3.21
bundle update mysql2 #installed mysql2-0.3.21 version

答案 1 :(得分:1)

正如对此线程的更新一样,指定gem的平台为我做了工作;

gem uninstall mysql2
gem install mysql2 --platform=ruby

这是我的版本详情:

Windows OS
Ruby 2.5.0p0 (2017-12-25 revision 61468) [i386-mingw32]
Rails 5.1.6
Gemfile:
  gem 'mysql2', '0.5.1'