Errors with gem install mysql2 - mysql

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'

Related

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

Rails 5 and Ruby 2.3.3 Failed to load libmysql.dll

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'

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

Gem installation error during MYSQL gem installation in ruby

I tried to install ruby gems in my windows 8 but i shows some error after someone told to use another way as given below
subst X: "C:\Program Files\MySQL\MySQL Server 5.6\bin"
gem install mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib\opt
subst X: /D
i tried using this ways everthing works but one error that is
mysql.h is missing
now what to do with this error?
You need to install mysql before installing mysql gem. Follow this link on how to install mysql on windows

gem install mysql failure in Snow Leopard

I successfully installed MySql x86_64 in Snow Leopard and Ruby and Ruby Gems seems to be installed properly:
$ which mysql
/usr/local/mysql/bin/mysql
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem
$ mysql
Your MySQL connection id is 404
Server version: 5.1.37 MySQL Community Server (GPL)
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.5
Unfortunatly I get an error installing mysql gem:
$ sudo gem update --system
...
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
I think you should try to uninstall the old mysql gem first before recompiling
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Installing the Xcode that's bundled with the Snow Leopard fixed the problem.
For me, it was adding the UNIX Tools option (if I recalled the name accurately), which include the headers. When I installed XCode originally, I didn't include this component because I didn't think that I would be writing UNIX code. Little did I know...
If you've installed MySQL 5 using MacPorts, then use the command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
I had this problem when I updated to Lion. In this case, I when to the app store and downloaded the latest Xcode. Then I uninstalled and reinstalled the database.
The issue had to do with a broken link during the update. Ruby likes to be in /System while Apple places ruby in /Developer.
was stuck with same problem:
Tried most of the solution's: At the end
Edit the app/config/database.yml, change the adapter to mysql2
production:
adapter: mysql2
database: commissi_production
username: root
password: root
host: localhost
& run on terminal
gem install activerecord-mysql2-adapter
Solved the problem.