Error installing mysql2 with windows 7 x64 does not work - mysql

Problem is quite simple, my OS is win 7 x64, I installed DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe, it works well like this:
C:\DevKit>ruby dk.rb install
[INFO] Skipping existing gem override for 'C:/Ruby192'
[WARN] Skipping existing DevKit helper library for 'C:/Ruby192'
C:\DevKit>gem install rdiscount --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed rdiscount-1.6.8
1 gem installed
Installing ri documentation for rdiscount-1.6.8...
Installing RDoc documentation for rdiscount-1.6.8...
C:\DevKit>ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello Ru
byInstaller**').to_html"
<p><strong>Hello RubyInstaller</strong></p>
then I'm installing mysql2 like this: gem install mysql2 --platform=ruby
I got the following problem:
gem install mysql2 --platform=ruby
Fetching: mysql2-0.3.10.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby192/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
3.10 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/ext/mysql2/g
em_make.out
what should I do?
thanks a lot!

it can't find mysql. did you have installed mysql?

for windows x86:
gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'
to install specific version, like v 0.3.10
gem install mysql2 -v '0.3.10' --platform=ruby -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'
for windows x64
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.35" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

Related

ERROR: Error installing mysql2: ERROR: Failed to build gem native extension

I am having some problems when trying to install gem install mysql2 -v '0.3.17' for Rails. When I try to install it by running gem install mysql2 -v '0.3.17' or gem install mysql2 -v '0.3.17' it gives me the following error:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysql-config
--without-mysql-config
Gem files will remain installed in `..../gems/ruby-1.9.3-p392/gems/mysql2-0.3.17 for inspection`.
Results logged to `.../gems/ruby-1.9.3-p392/extensions/x86_64-darwin-14/1.9.1/mysql2-0.3.17/gem_make.out`
How can I fix this and successfully install mysql2?
Thanks all .
I am in Ubuntu 15.04 and I got the same error as stated above.
I did :
sudo apt-get install libmysqlclient-dev
After this I did:
gem install mysql2
And now I can successfully do
rails new <app_name> -d mysql
without any errors.
Install libmysqlclient-devel:
CentOS/Fedora:
yum install -y libmysqlclient-devel
Ubuntu:
apt-get install -y libmysqlclient-dev
Mac:
brew install mysql
Hope it helps.
hi this might be happening for two reason.
1) You did not install your mysql server for that try
$ brew install mysql
2) didn't specified mysql_config when you are trying to install mysql2 for this try with
$ gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.6.24/bin/mysql_config
You need to install MySQL server first. You probably don't have it at the moment.

Can't Install gem install mysql2 Ruby WINx64

I've been searching for this error, reinstaled everything, and tried everthing. All I found here are old posts, and old versions.
Yes, I've downloaded MySQL C Connector and move the lib to that ruby dir. Still nothing.
Im running a PC WINx64
Ruby version 2.0.0-p195
Lastest Version of DevKit
**gem install mysql2**
**Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby200/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql-2.9.1 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/mysql_api/gem_make.out**
B:\ROR\hcv>
Windows is giving me problems all time. But this is all I have at Work. Thank You guys.
I've downloaded the connector from http://dev.mysql.com/downloads/mirror.php?id=412857
and typed in the command prompt
gem install mysql --platform=ruby -- --with-mysql-include=C:\mysql-connector-c-6.1.0-winx64\include --with-mysql-lib=C:\mysql-connector-c-6.1.0-winx64\lib
Try to install the mysql gem using following command
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.0\lib\opt" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.0\include"'
note: Change the mysql installation directory as per your installation

Installing MySQL with rails without Xcode

Is there anyway I could install MySQL gem for rails without Xcode? Many sites have mentioned XCode as optional requirement for installation. But Command line tools is installed.
I have installed rails , ruby, homebrew, MacPorts without XCode.But MySql gem could not be installed
Note: I have installed Command line tools for Xcode. But not full Xcode.
I have followed these references,
http://scotty-t.com/2012/04/02/intstalling-mysql-5-5-on-os-x-mountain-lion/
With setting path in bash_profile
But I keep on getting these errors while trying
sudo gem install mysql
Errors
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
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
* extconf.rb failed *
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.9.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.9.0/ext/mysql_api/gem_make.out
Should I install XCode first? Thanks in advance!
While you exec sudo gem install mysql, you're installing a gem which names mysql, not the database. This gem depende on a file named libmysql, which come with the mysql database.
In other words, you have to install mysql db on your machine first, then install the gem. Otherwise, the gem can't build because it can't find the file it need.
Since you have homebrew, you can install mysql db by exec brew install mysql. After that, sudo gem install mysql could work.
Do you have installed mysql-devel ? If not, try this
$ sudo yum install mysql-devel ;sorry it's for fedora
do it for lion, then
$ gem install mysql
If there still is error, try add a config path when you install the gem.

Mac OS 10.6 Server can't install mysql gem

I have nearly the same problem with the one discussed on the link below:
Error installing Mysql2 gem- 10.6 Server
I have followed the solution described but I get this:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-mysql-config
Gem files will remain installed in /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7 for inspection.
Results logged to /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7/ext/mysql2/gem_make.out
Additionally I also tried to specified all mysql path:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql --
--with-mysql-dir=/usr/local/mysql
--with-mysql-lib=/usr/local/mysql/lib
--with-mysql-include=/usr/local/mysql/include
--with-mysql-config=/usr/local/mysql/bin/mysql_config
And still get the error
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-mysql-config
Gem files will remain installed in /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7 for inspection.
Results logged to /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7/ext/mysql2/gem_make.out
Any help apreciated.
Do you have the mysql header files actually installed in the paths you link to? Have you installed a package of mysql that includes the header file?
/usr/local/mysql
I have installed mysql with ports and I have it in /opt
$ find /opt -name mysql.h
/opt/local/include/mysql5/mysql/mysql.h
you could try
$ find /usr/local -name mysql.h
I backtracked to version 5.1.59 of mysql instead of 5.5 and it worked fine.
It seems the gem is still incompatible with MySQL 5.5.xx

Error installing Mysql2 gem- 10.6 Server

I'm trying to install the mysql2 gem on 10.6 server and I get an error message I haven't seen:
EBuilding native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
I've tried a couple things, specifying where the built-in MySQL is stored sudo gem install mysql2 -- --with-mysql-dir=/var/mysql and also replacing the built-in mysql with the pre-built 64-bit installer from mysql.com
Any ideas?
Figured it out:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I found out you have to have the package mysql-devel installed ... On Centos
do yum -y install mysql-devel and you're good to go.
I have the same problem on OSX 10.5 with RVM with the "system" Ruby interpreter. Using Ruby 1.8.7 through RVM fixed the situation.
I was inspired by: https://gist.github.com/440334#file_gistfile1.txt