views:

5875

answers:

5

I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line. I run the command gem install mysql and I receive the following:

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 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:7: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 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. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

I've searched, and tried a whole host of things, from installing specific versions to trying to reinstall ruby without any luck.

Any ideas where I may be going wrong?

I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line. I run the command gem install mysql and I receive the following:

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 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:7: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 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. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

I've searched, and tried a whole host of things, from installing specific versions to trying to reinstall ruby without any luck.

Any ideas where I may be going wrong?

EDIT: I installed XCode off my Snow Leopard DVD and the error just changed slightly to the following:

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 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:7: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:17: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

doing "which mysql" on the command line returns nothing, which means it's not recognizing it. I also installed the MySQL system preferences option, and I can't stop MySQL from running. Now I'm completely stuck as what to do!

EDIT EDIT

I've just completely reinstalled MySQL using this guide http://hivelogic.com/articles/installing-mysql-on-mac-os-x

Unfortunately this didn't work either, I still receive the same errors. I can't even do mysql -uroot at the command line, I get the error of:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

So I think I've tried everything.

*SOLVED

Sorry guys, the reason for this not working was because of the MySQL paths. I've blogged on it here: http://www.kieransenior.co.uk/2010/02/04/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard/

A: 

you can try to reinstall the latest version of xcode / dev. tools for snow leopard - this should fix your errors

roman
This was one of the first things I did. Snow Leopard's version of XCode is installed on my machine.
Kezzer
A: 

if you are installing from source here is a tutorial.would be happy if it helps http://raihan90.blogspot.com/2009/03/mysql-step-by-step-hacking-into-mysql.html

Raihan Alam
A: 

Attention: You need to specify -- key, and than --with-mysql-config=/usr/local/mysql/bin/mysql_config

Vestel
Again, this answer is floating in many-a-place. In my instance, it doesn't work. Plus, mysql didn't exist for me in /usr/local/ I believe.
Kezzer
+3  A: 

First of all you need to differentiate between the MySQL as Server, MySQL as Client and the Ruby bindings to MySQL.

I'm not familiar with Mac, but for *nix OS you need to install MySQL through your package manager. To get the Ruby bindings installed with

gem install mysql

you need the development headers of ruby (in Ubuntu it is the package ruby-dev) and the development headers of the MySQL-Client (currently libmysqlclient16-dev in Ubuntu). I don't know if they are named different on Mac, but after you got those installed the Ruby bindings should install without any error.

Aurril
Indubitably, there is a multi-packaged version which does both. I've gone through this process as well. I think you're right, I do need to differentiate between the two as this has been mainly my problem. Another option, perhaps, is to install MAMP and use that? What would I need then?
Kezzer
MAMP stands for Mac, Apache, MySQL, Php.So you would still need a MySQL-Server and in addition Apache 2, and the php libraries for apache. I'm not sure if you can just select MAMP in your package manager and it will install all required files. Maybe a Mac user could help you out there.
Aurril
Indeed it would fall short of the need for MAMP, but it was just an easy way to serve up a MySQL instance.
Kezzer
This was exactly what I needed on Ubuntu: `sudo apt-get install ruby-dev` and `sudo gem install mysql`. Thanks!
Dan Breslau
yep, this worked: 'sudo apt-get install ruby-dev libmysqlclient16-dev' then 'sudo gem install mysql'
Travis R
Thanks Aurril - ruby-dev is what was missing in my case!
nevelis
+3  A: 

http://trevoke.net/blog/2009/04/17/installing-the-mysql-gem-on-osx/

in a terminal.. First do a ‘locate mysql_config’ and then replace the path in the following command with where that file is.

$ sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.7
1 gem installed
Trevoke
This looks good, I'll have to try it when I'm back at home perhaps. Cheers.
Kezzer