# MySQL Installation Issues

**URL:** <https://www.ruby-forum.com/t/mysql-installation-issues/121662>\
**Category:** Rails\
**Created:** [November 29, 2007, 6:33pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662 "2007-11-29T18:33:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 29, 2007, 6:33pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/1 "2007-11-29T18:33:13Z")

</div>

Hello-

Trying to get rails up and running on my linux box with mysql. When I  
try to install the mysql gem, I get the following:

Building native extensions. This could take a while…  
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql  
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  
\*\*\* 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/local/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

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/  
mysql-2.7 for inspection.  
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/  
gem\_make.out

I’ve tried setting the config option and other various things when  
running ‘gem install’.

Anyone know how to get around this? Thanks very much.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 29, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/2 "2007-11-29T18:40:52Z")

</div>

On Nov 29, 2007 11:32 AM, pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Trying to get rails up and running on my linux box with mysql. When I  
> try to install the mysql gem, I get the following:
> 
> Building native extensions. This could take a while…  
> ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
> ERROR: Failed to build gem native extension.

cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7  
gem install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 29, 2007, 6:49pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/3 "2007-11-29T18:49:04Z")

</div>

Thanks for the quick response.

No success with that either:

Building native extensions. This could take a while…  
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql – --with-mysql-config=/usr/local/mysql/  
bin/mysql\_config  
extconf.rb:1: command not found: /usr/local/mysql/bin/mysql\_config –  
cflags  
\*\*\* 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/local/bin/ruby  
–with-mysql-config

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/  
mysql-2.7 for inspection.  
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/  
gem\_make.out

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 30, 2007, 5:19pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/4 "2007-11-30T17:19:32Z")

</div>

It compiles and installs a mysql driver used by ruby. You must have a  
previously installed version of mysql including headers and libraries.

-Bill

pete wrote:

> > ruby extconf.rb install mysql – --with-mysql-config=/usr/local/mysql/  
> > –without-opt-dir
> > 
> > > > Trying to get rails up and running on my linux box with mysql. When I  
> > > > Greg D.[http://destiney.com/](http://destiney.com/)

–  
Sincerely,

William P.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 30, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/5 "2007-11-30T17:06:40Z")

</div>

This is still not working and I have tried almost every configuration  
option possible.

As a side question…when you run ‘gem install mysql’, what exactly  
does this do?

Does it create a binding to an already installed version of MySQL?  
Does it install MySQL??

Thanks!

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 30, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/6 "2007-11-30T17:44:45Z")

</div>

It should work ok with 4.1or 5, but if I remember right, it recommends  
5. I am using the latest 5 with no problems (5.0.45 I think).

-Bill

pete wrote:

> > -Bill
> > 
> > > > necessary libraries and/or headers. Check the mkmf.log file for more  
> > > > –without-make-prog  
> > > > On Nov 29, 10:40 am, “Greg D.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > > > 
> > > > > cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7

–  
Sincerely,

William P.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 30, 2007, 5:23pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/7 "2007-11-30T17:23:39Z")

</div>

Thanks Bill.

Is there a dependency on the version of MySQL, I believe I am running  
an older version.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 30, 2007, 6:12pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/8 "2007-11-30T18:12:51Z")

</div>

What about MySQL client? I don’t believe the client is installed,  
only the server.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 30, 2007, 6:35pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/9 "2007-11-30T18:35:49Z")

</div>

It’s very possible that it is looking for libmysqlclient (I am almost  
positive it does). Install the client / client libs and see if that  
solves your problem.

-Bill

pete wrote:

> > > > It compiles and installs a mysql driver used by ruby. You must have a
> > > > 
> > > > > does this do?
> > > > > 
> > > > > > No success with that either:  
> > > > > > Could not create Makefile due to some reason, probably lack of  
> > > > > > –with-make-prog
> > > > > > 
> > > > > > > >
> > 
> > –  
> > Sincerely,
> > 
> > William P.

–  
Sincerely,

William P.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [January 26, 2009, 2:23pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/10 "2009-01-26T14:23:25Z")

</div>

I was facing this same issue. I just installed libmysqlclient15-dev on  
my syste (ubuntu 8.10) and could get gem mysql installed successfully

William P. wrote:

> It’s very possible that it is looking for libmysqlclient (I am almost  
> positive it does). Install the client / client libs and see if that  
> solves your problem.
> 
> -Bill

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [January 14, 2008, 3:54am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/11 "2008-01-14T03:54:58Z")

</div>

Greg D. wrote:

> On Nov 29, 2007 11:32 AM, pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Trying to get rails up and running on my linux box with mysql. When I  
> > try to install the mysql gem, I get the following:
> > 
> > Building native extensions. This could take a while…  
> > ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
> > ERROR: Failed to build gem native extension.
> 
> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7  
> gem install mysql –  
> –with-mysql-config=/usr/local/mysql/bin/mysql\_config
> 
> –  
> Greg D.  
> [http://destiney.com/](http://destiney.com/)

This fixed worked for me on OS X Tiger. Thanks! I have MySQL 5.0.45  
installed along with the MySQL GUI tools.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [April 5, 2009, 8:02am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/12 "2009-04-05T08:02:58Z")

</div>

This worked for me also.

Wainer Moschetta wrote:

> I was facing this same issue. I just installed libmysqlclient15-dev on  
> my syste (ubuntu 8.10) and could get gem mysql installed successfully
> 
> William P. wrote:
> 
> > It’s very possible that it is looking for libmysqlclient (I am almost  
> > positive it does). Install the client / client libs and see if that  
> > solves your problem.
> > 
> > -Bill

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [May 5, 2009, 1:14am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/13 "2009-05-05T01:14:49Z")

</div>

Greg D. wrote:

> On Nov 29, 2007 11:32 AM, pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Trying to get rails up and running on my linux box with mysql. When I  
> > try to install the mysql gem, I get the following:
> > 
> > Building native extensions. This could take a while…  
> > ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
> > ERROR: Failed to build gem native extension.
> 
> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7  
> gem install mysql –  
> –with-mysql-config=/usr/local/mysql/bin/mysql\_config
> 
> –  
> Greg D.  
> [http://destiney.com/](http://destiney.com/)

This worked for me on Mac OS X Leopard with MySQL 5.1.34. In particular,  
the following command worked:

sudo gem install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [April 1, 2009, 8:26pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/14 "2009-04-01T20:26:42Z")

</div>

> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7  
> gem install mysql –  
> –with-mysql-config=/usr/local/mysql/bin/mysql\_config  
> Greg D.  
> [http://destiney.com/](http://destiney.com/)

YUP. this works.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [June 22, 2009, 9:37am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/15 "2009-06-22T09:37:02Z")

</div>

I found a blog post that solves this problem ( [Nathan Manzi's Blog | Home](http://nmanzi.com/?p=39)  
) and I turned it into a script so that you just have to run “./  
install\_mysql\_ruby\_adapter”

> **[GitHub - thirdreplicator/install\_mysql\_ruby\_adapter\_for\_ruby1.9: This is a Unix...](https://github.com/thirdreplicator/install_mysql_ruby_adapter_for_ruby1.9/tree/master)**
>
> master

I run Ruby 1.9.1 on Ubuntu 8.04/8.10 and CentOS 5.2 with root  
access.

David 🙂

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [June 3, 2009, 8:43am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/16 "2009-06-03T08:43:43Z")

</div>

I tried:

\<-- clip starts --\>  
[root]# gem install mysql – --with-mysql-config=/usr/bin/mysql\_config  
Building native extensions. This could take a while…  
ERROR: Error installing mysql:  
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql –  
–with-mysql-config=/usr/bin/mysql\_config  
checking for mysql\_ssl\_set()… 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=/usr/local/bin/ruby  
–with-mysql-config

Gem files will remain installed in  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.  
Results logged to  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem\_make.out  
\<-- clip ends --\>

Steps I needed on CentOS 5 linux were (in addition to installed ‘normal’  
mysql)

1. Install mysql-devel “yum install mysql-devel” as root
2. Find the location of mysql\_config “locate mysql\_config” and fix that  
full path to “–with-mysql-config=” option
3. Success!

\<-- clip starts --\>  
[root]# gem install mysql –  
–with-mysql-config=/usr/lib/mysql/mysql\_config  
Building native extensions. This could take a while…  
Successfully installed mysql-2.7  
1 gem installed  
\<-- clip ends --\>

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [November 2, 2009, 12:12am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/17 "2009-11-02T00:12:19Z")

</div>

Greg D. wrote:

> ## cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 gem install mysql – –with-mysql-config=/usr/local/mysql/bin/mysql\_config
> 
> Greg D.  
> [http://destiney.com/](http://destiney.com/)

Worked for me too.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [February 7, 2010, 6:02pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/18 "2010-02-07T18:02:29Z")

</div>

I got it working following these steps:

1. Install mysql-devel “yum install mysql-devel” as root
2. Find the location of mysql\_config “locate mysql\_config” and fix that  
full path to “–with-mysql-config=” option
3. Success!

Best regards.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [August 6, 2009, 9:57pm UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/19 "2009-08-06T21:57:56Z")

</div>

Whenever you can’t build “native extensions”, it means there is some lib  
or lib-dev missing. Generally you’ll need to do a sudo apt-get install  
lib-???-dev, or sudo apt-get install build\_essential.

This time, I had to install the following:  
‘sudo apt-get install libmysqlclient15-dev’

Unfortunately, there is NO EASY WAY (that I know of) to identify what is  
missing from the attempt to compile.

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [March 21, 2010, 1:48am UTC](https://www.ruby-forum.com/t/mysql-installation-issues/121662/20 "2010-03-21T01:48:29Z")

</div>

Abraham Tio wrote:

> > cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7  
> > gem install mysql –  
> > –with-mysql-config=/usr/local/mysql/bin/mysql\_config  
> > Greg D.  
> > [http://destiney.com/](http://destiney.com/)
> 
> YUP. this works.

newbie question…

I was able to get an error free install on OSX Leopard 10.6.2 with the  
following. The first cds to the mysql gem location of my Leopard install  
(may differ for others):

cd /Library/Ruby/Gems/1.8/gems/mysql-2.8.1  
sudo gem install mysql --no-rdoc --no-ri –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config

There were many “No definition for…” RDoc and Ri errors otherwise.

Just starting my first Ruby project… and not so comfortable with this  
install of the mysql gem. I expect there’s possibly serious  
ramifications of excluding these two processes. Can anybody tell us what  
are we missing by resorting to these install parameters; and/or how can  
we install with ri and rdoc successfully?

tia

m

[Next page](https://www.ruby-forum.com/t/mysql-installation-issues/121662.md?page=2)
