I am trying to install the mysql 2.8.1 gem. I would be using it to build a Rails 2.0.2 application on Ubuntu 10.04. I would be using Ruby 1.8.7. I have installed the development dependencies(other gems). For some reasons I am unable to install it. I am not able to exactly figure out how to fix it. Please help!!
I get the following in the terminal when I try to install it:
mohnish#pc146724-desktop:~/Downloads$ sudo gem install mysql-2.8.1.gem
Building native extensions. This could take a while...
ERROR: Error installing mysql-2.8.1.gem:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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=/usr/bin/ruby1.8
--with-mysql-config
--without-mysql-config
--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-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
mohnish#pc146724-desktop:~/Downloads$
Thanks for your help!!
Try this and then install the mysql gem:
sudo apt-get install libmysqlclient-dev
If that's not sufficient try it like this
sudo apt-get install libmysqlclient-dev libmysqlclient16 ruby-dev
Try this and then install the mysql gem:
sudo apt-get install libmysqlclient-dev libmysqlclient16
This worked after then running sudo gem install mysql.
The documentation still doesn't install correctly (heaps of "No definition" errors, although thats not really a biggie.
You should do what the error message tells you: check the mkmf.log! Search for this file using find /usr/lib/ruby/gems/1.8/gems/ -name mkmf.log. Usually, this error message appears because you forgot to install the -dev package for the extension you were trying to install. So if you wanted to install the mysql gem, you probably forgot to install the libmysqlclient14-dev first. Do an apt-cache search | grep dev to find the appropriate packages.
plz check this for more information
In my case, I had the following error message:
An error occurred while installing mysql (2.8.1), and Bundler cannot
continue. Make sure that gem install mysql -v '2.8.1' succeeds
before bundling.
I tried: gem install mysql -v '2.8.1', and I got an error message similar to what you got.
I fixed it doing the following:
STEP (1): run this: sudo apt-get install libmysqlclient-dev
STEP (2): install mysql: gem install mysql -v 2.8.1
You should get a success message similar to this:
Successfully installed mysql-2.8.1 Installing ri documentation for
mysql-2.8.1 1 gem installed
I hope my answer helps.
Related
I am trying to use the mysql 2 gem with Rails, so I added gem 'mysql2'. I am not able to install it using bundle install, and it gives me this error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/Ben/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150307-17143-1jx7cob.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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
--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/Ben/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--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
--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-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
extconf failed, exit code 1
Gem files will remain installed in /Users/Ben/.rvm/gems/ruby-2.2.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/Ben/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.
I have no idea how to get it to work, so any help would be appreciated.
Here is some info on my computer.
ruby -v => ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
gem 'rails', '4.1.5' (rails -v won't work)
bundler -v => Bundler version 1.8.4
OS: Mac Yosemite
For Mac Users:
brew install mysql
gem install mysql2
For Ubuntu Users:
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
sudo gem install mysql2
Installing the libmysqlclient-dev gives you the necessary files to compile the mysql2 gem which is what Rails will use to connect to MySQL when you setup your Rails app.
Finally, run bundle install
try to install 'libmysqlclient-dev' first
sudo apt-get install libmysqlclient-dev
and after run
bundle install
Make sure that you install your gems using bundler.
Run
bundle install
or simply
gem install mysql2
Then include it in your database.yml file
I figured out my problem, I was running rails server in RubyMine, but for some reason, RM was using an old version of ruby. Changing the project's sdks worked perfectly!
Not an OS specific answer, but may help others:
Newer MySQL2 adapters (v0.4.x) are not compatible with Rails 4.1.5.
Specifying an older mysql2 gem (eg v0.3.x) fixes the issue:
gem 'mysql2', '~> 0.3.21'
Source: https://github.com/brianmario/mysql2/issues/675
When I attempt to run the following in Terminal, I receive an error that prevents the installation of mysql gem:
I run:
sudo gem install mysql
I receive the following error:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/(myuseraccount)/.rbenv/versions/2.1.5/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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=/Users/(myuseraccount)/.rbenv/versions/2.1.5/bin/ruby
--with-mysql-config
--without-mysql-config
--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-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
extconf failed, exit code 1
Gem files will remain installed in /Users/(myuseraccount)/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/mysql-2.9.1 for inspection.
Results logged to /Users/(myuseraccount)/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/mysql-2.9.1/gem_make.out
Please tell me if you know how I can fix this error and install the mysql gem
Install mysql2 gem rather than mysql and be sure to have MySql installed before install the gem:
brew install mysql
gem install mysql2
bundle install
Error was:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
..................
An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.4.10' succeeds before bundling.
...................
Solution was:
gem update --system
sudo apt-get install libmysqlclient-dev
And then "bundle install" was OK.
I'm having a bunch of problems installing the mysql2 gem on Ruby, I've tried a lot of guides, but nothing seems to be working... Here's the error when I try to install it, without any extra commands.
C:\Users\Julián>gem install mysql2 --no-rdoc --no-ri
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:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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-x64/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-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql
2-0.3.16 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.
0/mysql2-0.3.16/gem_make.out
I'm really stumped, I tried to find a solution around here but couldn't find anything. I tried installing MySQL connectors and setting with-mysql-lib commands. Please help!
Since it appears you're using Windows, you need to consider you have to install the MYSQL C-Connector header files to get it to work
We've written a tutorial about this here
--
You'll want to use the following steps:
Install the MYSQL C-Connector files (without any spaces in path)
Install the MYSQL2 gem again (with correct path references)
Copy lbmysql.dll to your ruby/bin folder
Firstly, you'll want to downlaod the MYSQL C-Connector files:
It has to be 32-bit C-Connector
Once you've installed this into a path with no spaces, you can then use the mysql2 installation command again, with config options:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-path"'
After this, you can then transfer libmysql.dll from your mysql files to your ruby/bin directory:
in a terminal.. First do a ‘locate mysql_config’ and then replace the path in the following command with where that file is.
gem install mysql2 --no-rdoc --no-ri --with-mysql-config=path
I'm trying to use vagrant on my MAC OSX machine. I connected vagrant with using SSH and I set ruby 1.9.2-p290. Now I'm try to install ruby gems but I've been facing with this problem when I want to install mysql2 gem.
Fetching: mysql-2.8.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/home/vagrant/.rbenv/versions/1.9.2-p290/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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=/home/vagrant/.rbenv/versions/1.9.2-p290/bin/ruby
--with-mysql-config
--without-mysql-config
--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-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
Gem files will remain installed in /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
I set in Gem file
gem 'mysql2'
and again I run bundle command but the result is the same.
Why doesn't mysql run on vagrant?
The mysql2 gem has native C extensions that build against mysql binaries.
Your vagrant machine needs to have mysql installed.
Do something like this
$ vagrant ssh
$ sudo apt-get install mysql-server mysql-client
After mysql is installed, you should be able to install the mysql2 gem.
EDIT: you also need the mysql development libraries so
$ sudo apt-get install libmysqlclient-dev libmysqlclient16 ruby-dev
There's not much more to my question than that. gem install mysql doesn't work and I haven't found anything by Googling.
When I try gem install mysql2, this is what I get. I don't know what to do now.
jason#buster:~/projects/mcif-rails$ gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/home/jason/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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=/home/jason/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
--with-mysql-config
--without-mysql-config
--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-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
Gem files will remain installed in /home/jason/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6 for inspection.
Results logged to /home/jason/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
It looks like you still need to install MySQL's development libraries. These are required for the gem to build successfully on your system.
[Edit] Seems the RoR Wiki is no longer available. But, Ubuntu has offered their own walkthrough which suggests:
sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql
See http://wiki.rubyonrails.org/database-support/mysql#installation for more detail.
Example: Ubuntu
sudo apt-get install mysql-server mysql-server-5.0 libmysqlclient15off \
libmysqlclient15-dev mysql-client-5.0 mysql-common
sudo apt-get install libmysql++-dev
sudo gem install mysql
I'll just leave this here:
I ran into a similar problem, then realized I couldn't install the mysql2 gem without having MySQL installed on my development machine (even though I'm only using the mysql2 gem to connect to a remote MySQL server).
::forehead slap::
brew install mysql
then, in my Gemfile:
gem 'mysql2', '~> 0.3.11'
followed by a quick
bundle install
Success!
If you are running Rails 3 you should use the mysql2 gem. You can install it with:
gem install mysql2
You will need to first install MySQL and any development headers. This will vary across different operating systems. On Ubuntu, you can run:
aptitude install mysql-server
aptitude install mysql-client
aptitude install mysql-common
aptitude install libmysql-ruby
aptitude install libmysqlclient-dev
If you are creating a new project, use:
rails new sample --database=mysql
cd sample
bundle install
For more details, check out the project repository.
I assume you are working with Rails.
In your Gemfile:
gem 'mysql2'
Then in your terminal:
bundle
In 2013, Using Ubuntu 12.04, this worked for me:
sudo apt-get install mysql-client libmysqlclient-dev
bundle install