Rails 5 和 Ruby 2.3.3 加载失败 libmysql.dll

Rails 5 and Ruby 2.3.3 Failed to load libmysql.dll

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

Failed to load libmysql.dll from C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems.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))

Post 安装来自 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'