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

在为使用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. 

我从这里尝试了解决方案,但没有奏效。

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

将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 

就像对这个线程的更新一样,指定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'