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/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard/
On Debian (or Ubuntu) systems, just install libmysqlclient-dev package using:
sudo apt-get install libmysqlclient-dev
and then:
gem install mysql
It will be installed without any error.
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
gem install mysql -- --with-mysql-config=/Applications/XAMPP/bin/mysql_config
. No sudo required!
sudo locate mysql_config
to get the config paths. Otherwise, it return the message: WARNING: The locate database (/var/db/locate.database) does not exist. ...
sudo gem install mysql1 etc
like in this answer :)
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.
sudo apt-get install ruby-dev
and sudo gem install mysql
. Thanks!
A number of people found this post helpful.
Also, I needed to do first type this:
yum install mysql-devel
and then:
gem install mysql
For some people you may need to type:
gem install mysql -- --with-mysql-config=/usr/local/mysql/mysql_config
on OSX mountain Lion: If you have brew
installed, then brew install mysql
and follow the instructions
on creating a test database with mysql on your machine. You don't have to go all the way through, I didn't need to After I did that I was able to bundle install and rake.
In order to resolve
Gem::Ext::BuildError: ERROR: Failed to build gem native extension error for mysql2, I think libmysql-ruby got changed with ruby-mysql
Simply try with following commands,
sudo apt-get install ruby-mysql
& then
sudo apt-get install libmysqlclient-dev
I had a similar experience, so here are the things that I tried
Firstly, I tried to install mysql's required packages by running the command below in my terminal
sudo apt-get install build-essential libmysqlclient-dev
Secondly, I tried updating rubygems on my system by running the command below in my terminal
sudo gem update --system
But I was still experiencing the same issue.
Here’s what worked for me
After much research I realized that I was using an almost out-of-date version of the mysql gem. I simply needed to use the mysql2 gem (mysql2 gem)and not the mysql gem, so I fixed it by running the command below in my terminal
gem install mysql2
This worked fine for me. Before running the last command, ensure that you've ran the first and second commands to be sure that everything is fine on your system.
That's all.
I hope this helps
gem install mysql2
thank you
I had also forgotten to actually install MySQL in the first place. Following this guide helped a lot.
http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/
As well as adding these lines to my .profile:
export PATH="/usr/local/mysql/bin:$PATH"
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
you can try to reinstall the latest version of xcode / dev. tools for snow leopard - this should fix your errors
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
Attention: You need to specify -- key, and than --with-mysql-config=/usr/local/mysql/bin/mysql_config
If you use Percona Mysql server
$ yum install Percona-Server-devel-55
$ gem install mysql
yum -y install gcc mysql-devel ruby-devel rubygems
gem install mysql2
Your Ubuntu OS need to install library for mysql client sudo apt-get install libmysqlclient-dev
After That just install bundle
or bundle install
Success story sharing