Rails 5 and Ruby 2.3.3 Failed to load libmysql.dll - mysql

Getting below error message logged in the console while starting the server for an application created with mysql database.
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
Environment Details :
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 install message from mysql2 ruby gem received below message on the console.
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.
I have tried the solution from here but did not work.
Any help appreciated, thanks in advance.

Downgrading mysql2 rubygem from version 0.4.7 to 0.3.21 solved my issue.
Below steps I followed
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

Just as an update to this thread, specifying the platform of the gem did the job for me;
gem uninstall mysql2
gem install mysql2 --platform=ruby
And here is my version details:
Windows OS
Ruby 2.5.0p0 (2017-12-25 revision 61468) [i386-mingw32]
Rails 5.1.6
Gemfile:
gem 'mysql2', '0.5.1'

Related

I got the following error while running gem install mysql2 on windows 10

I downloaded and installed ruby from this https://rubyinstaller.org/downloads/ -> Ruby+Devkit 2.7.3-1 (x64) and follow the installation steps. but I got a error when I tried to install mysql2 for rails using
gem install mysql2
ruby version is 2.7.3p183
rails version is 6.1.3.2
gem version is 3.1.6
ERROR: Error installing mysql2:
The last version of mysql2 (>= 0) to support your Ruby & RubyGems was 0.5.3. Try installing it with gem install mysql2 -v 0.5.3
mysql2 requires Ruby version >= 2.2, < 2.7.dev. The current ruby version is 2.7.3.183.
I tried gem install mysql2 -v 0.5.3 but got same error.
I installed mysql before running this command, and I also have mysql on XAMPP.
I installed MYSQL using mysql-installer-web-community-8.0.25.0
I uninstalled my current ruby and reinstalled with rubyinstaller-devkit-2.6.7-1-x64.exe and it works.
I'd move to linux ubuntu or Mac for dev you'll get a lot more support and workarounds if needed. For ruby support on windows is non-existent. Not all gems work.

How can I solve this Mysql2 gem error in CentOS 8?

I need to setup ruby on rails with MySQL
I already have installed MYSQL
when I do Bundle install it shows following error.
Fetching mysql2 0.3.21
Installing mysql2 0.3.21 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
I am using Cent-os 8
anyone can help
Thanks
Run first this command gem 'mysql2', '~> 0.3.21' in terminal and when finish then try bundle again

Errors with gem install mysql2

Hello i am having trouble installing mysql2 gem.
The first error i was getting was mysql client is missing. I have fixed this with the following
gem install mysql2 -- '--with-mysql-dir="C:\Program Files\MySQL\MySQL Server 5.7"'
I then get the message that is missing mysql.h
gem install mysql2 -- '--with-mysql-dir="C:\Program Files\MySQL\MySQL Server 5.7" --with-mysql-config="C:\Program Files\MySQL\MySQL Server 5.7\bin"'
I have tried \bin and \include \lib. i have tried different permutation of the last with-mysql to try and find the mysql.h and have been unsuccessful.
Any help will be greatly appreciated.
Thanks.
Not sure if this info is needed but just in case.
Gem --v is 2.2.3
Rails -v is 4.2.5
Ruby -v is 2.1.5p273 [i386-mingw32]
MySQL server version 5.7.9
Use this version
gem 'mysql2', '~> 0.3.19'

Unable to install "mysql2" gem on Linux (CentOS)

I am unable to install the "mysql2" gem on my CentOS linux machine.
I recently install mysql following the following tutorial: http://www.rackspace.com/knowledge_center/article/installing-mysql-server-on-centos
When I try to download "mysql2" gem I get the following log:
[root#vc2cmmka035538n ruby]# gem install mysql2
ERROR: Could not find a valid gem 'mysql2' (>= 0) in any repository
ERROR: Possible alternatives: mysql
Environment info:
Rails 3.2.3
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
gem -v 1.8.24
From their github page, quoted
This gem links against MySQL's libmysqlclient C shared library. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system.
So, you might wanna install those packages first. Then you can even manually compile the gem if you still face the problem.
https://github.com/brianmario/mysql2
If mysql repo is disabled on your system, here is the link about installing them
http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html

"Incorrect MySQL client library version"

I'm getting the following error when running rake assets:precompile
Incorrect MySQL client library version! This gem was compiled for 5.6.10 but the client library is 5.5.12.
MySQL is installed using Homebrew and is version 5.6.10. I can connect to the database on 127.0.0.1 locally.
I've tried the following with no luck:
ARCHFLAGS="-arch x86_64" gem install mysql2 -- –with-mysql-config=/usr/local/bin/mysql_config
It seems that advice is for folks whose "client library" is newer than the one the Gem was compiled for. My issue is the opposite. Can't figure out where the 5.5.12 is coming from. Any ideas?
Try:
gem uninstall mysql
gem uninstall mysql2
Then
bundle install