The system info relevant to my problem:
AWS RDS DB Instance
Instance Class - db.m1.small
Engine - MySQL 5.6.13
AWS EC2 Linux AMI
https://aws.amazon.com/amazon-linux-ami/2014.03-release-notes/
R version 3.0.2
i686-redhat-linux-gnu (32-bit)
Linux MySQL packages installed:
mysql.noarch 5.5-1.6.amzn1 #amzn-main
mysql-server.noarch 5.5-1.6.amzn1 #amzn-main
mysql55.i686 5.5.37-1.46.amzn1 #amzn-updates
mysql55-common.i686 5.5.37-1.46.amzn1 #amzn-updates
mysql55-libs.i686 5.5.37-1.46.amzn1 #amzn-updates
mysql55-server.i686 5.5.37-1.46.amzn1 #amzn-updates
I have R installed on the aforementioned AWS Linux AMI. I'm trying to pull data from my RDS instance running MySQL into R data frames.
As it stands currently, I have installed the DBI package into R, but installing RMySQL is failing with the following error:
$> R CMD INSTALL RMySQL_0.9-3.tar.gz
* installing to library ‘/usr/lib/R/library’
* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for compress in -lz... yes
checking for getopt_long in -lc... yes
checking for mysql_init in -lmysqlclient... no
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking /usr/local/include/mysql/mysql.h usability... no
checking /usr/local/include/mysql/mysql.h presence... no
checking for /usr/local/include/mysql/mysql.h... no
checking /usr/include/mysql/mysql.h usability... no
checking /usr/include/mysql/mysql.h presence... no
checking for /usr/include/mysql/mysql.h... no
checking /usr/local/mysql/include/mysql/mysql.h usability... no
checking /usr/local/mysql/include/mysql/mysql.h presence... no
checking for /usr/local/mysql/include/mysql/mysql.h... no
checking /opt/include/mysql/mysql.h usability... no
checking /opt/include/mysql/mysql.h presence... no
checking for /opt/include/mysql/mysql.h... no
checking /include/mysql/mysql.h usability... no
checking /include/mysql/mysql.h presence... no
checking for /include/mysql/mysql.h... no
Configuration error:
could not find the MySQL installation include and/or library
directories. Manually specify the location of the MySQL
libraries and the header files and re-run R CMD INSTALL.
INSTRUCTIONS:
1. Define and export the 2 shell variables PKG_CPPFLAGS and
PKG_LIBS to include the directory for header files (*.h)
and libraries, for example (using Bourne shell syntax):
export PKG_CPPFLAGS="-I<MySQL-include-dir>"
export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"
Re-run the R INSTALL command:
R CMD INSTALL RMySQL_<version>.tar.gz
2. Alternatively, you may pass the configure arguments
--with-mysql-dir=<base-dir> (distribution directory)
or
--with-mysql-inc=<base-inc> (where MySQL header files reside)
--with-mysql-lib=<base-lib> (where MySQL libraries reside)
in the call to R INSTALL --configure-args='...'
R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/usr/lib/R/library/RMySQL’
It's clear that I need to direct the installation to where MySQL is installed, but I don't know where to start to locate the proper directory. I did the following to try to look around:
$> find / -name mysql
/usr/share/mysql
/usr/lib/perl5/vendor_perl/auto/DBD/mysql
/usr/lib/perl5/vendor_perl/DBD/mysql
/usr/lib/mysql
/usr/bin/mysql
/var/lib/mysql
/var/lib/mysql/mysql
So there's a lot of different MySQL directories on my AWS Linux instance. Which one do I use in the installation path? Should I do trial and error?
My other question is (assuming I install RMySQL properly), does the MySQL server have to be running on the same physical (virtual?) machine where R is also installed in order for RMySQL to work?
Other research has shown that a SSH tunnel has to be created for the RMySQL connection to the MySQL database to work. Is this true? If I'm not mistaken, AWS RDS doesn't allow for SSH tunneling.
Any other suggestions?
You missed the most important line in the configure output:
checking for mysql.h... no
You have the run-time package(s) for MySQL installed. You now need the development packages.
Under Debian/Ubuntu we impose these Build-Depends (and I just edited away the minimal version requirements):
Build-Depends: debhelper, cdbs, r-base-dev, libmysqlclient-dev, r-cran-dbi
The first two are Debian-packaging internal, the third is R, the fourth is MySQL and you need to map that to whatever RH/FC call it and the last one is DBI for R.
When trying to run a rails server in my current directory (which is a new rails project), it says that I need to install the mysql2 gem. At first, I had no idea what this meant... Then, I did some poking around, and finally decided to install the gem. However, I am getting this super pesky error (seeing as I just spent 2 hours trying to investigate, and solve another error). I am on the brink of giving up, but I really want to try rails. Please help!
Currently, if I run sudo gem install mysql2, or even as some people told me to do online, gem install mysql -- \ --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config (I have MAMP), it gives me the following error:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/vicky/.rvm/rubies/ruby-2.0.0-p247/bin/ruby 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
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /Applications/MAMP/Library/lib
-----
creating Makefile
make "DESTDIR="
compiling client.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
Gem files will remain installed in /Users/username/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to /Users/username/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out
Have you considered installing MySQL with homebrew (http://brew.sh/)? MAMP stands for Mac-Apache-MySQL-PHP (the last part of this being the most important). I would suggest just installing MySQL directly on your box (homebrew takes care of all the heavy lifting) and afterwards I doubt you'll have any difficulty installing that gem.
To install homebrew --
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Run brew doctor follow any instructions and then afterwards to install MySQL run brew install mysql and follow any of the instructions it provides for setting up a user, etc...
============= UPDATE ==============
SO, what you'll want to do is use brew this way to install MySQL and then install the gem in the normal fashion - sudo gem install mysql2 assuming this works, then you will be able to switch back to the old MySQL install through MAMP via -
sudo nano /etc/paths
then add this line to the top of the document -
/Applications/MAMP/Library/bin
restart your terminal and then run mysql to double check that you are using the MAMP installation of MySQL, and you'll be good to go.
I installed Ruby 2.0.0 and DevKit from RuyInstaller. I have an error message when I'm creating new project:
rails new testtest -d mysql
..... a lot of output here ........
Installing mysql2 (0.3.14)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
C:/Ruby200/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.
How can I install dependencies to make this gem without any errors?
You need MySQL 32-bit (or MySQL Connector C) to compile mysql2 gem compiling on Windows (even if you are using a 64-bit version of the OS).
Follow these steps:
Download MySQL Server 32-bit .zip file (Alternatively MySQL Connector C is also fine)
Copy libmysql.dll to %RUBY_HOME%\bin (or simply add MySQL 32-bit lib directory to PATH)
Install mysql2 gem with --with-mysql-lib and --with-mysql-include options
gem install mysql2 -- '--with-mysql-lib="c:\path\to\32-bit-MySQL-Server\lib\opt" --with-mysql-include="c:\\path\to\32-bit-MySQL-Server\include"'
Here is my story. Tried to install mysql2 gem on windows 7 with devkit.
First you need to install connector libraries and headers.
Don't use default folder "Program Files", gem failed to include folders with spaces.
I've substed connector folder through subst X:\ "C:\Program File\Mysql Connector 6 C\"
and then used following cmd:
gem install mysql2 -- --with-mysql-dir=X:\
Then realised that I'm using 64 bit connector libraries with 32 bit ruby.
Reinstalled connector.
And then gem was successfully installed.
But failed to run, complaining on missing mysql dll. So, I've put libmysql.dll and *.lib to ruby\bin folder. And after all this was able to user mysql2 gem.
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
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.
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.
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
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 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
While these answers pointed me in the right direction, on Alpine linux the package I needed was mariadb-dev, eg. run apk add mariadb-dev before the gem install mysql command.
Running OS X Leopard an MacBook Pro from Jan. 2008.
I used to run mysql server from a package but then rails started putting a warning that I should install mysql from gem: gem install mysql
It did not work, I got the following error message:
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 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
... snip ...
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
Then I tried a different way, upon a friend's advice and tried to follow the excellent instructions at http://hivelogic.com/articles/2007/11/installing-mysql-on-mac-os-x
but now ran into a new problem when trying to run 'mysql -u root'
The message I get is:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I have googled my heart out trying to fix either problem and feel stuck. Thanks for reading and helping
To the first problem - I would imagine that Ruby gem is installing the ruby MySQL interface/drivers, not the MySQL server itself. It may be not present, or in a place the standard scripts can't find.
The second message indicates that the MySQL server is not running. Try starting it again, or examine any logs/messages for some indication as to why it might not be starting