MySQL gem installation problem - mysql

I'm bit confused having error with MySQL gem installation. I have uninstalled mysql gem because of MySQL update from 5.0.xx to 5.1.39 and now I can't install it properly.
I have downloaded mysql-2.8.1.gem to the server, because it is behind proxy. I have rad a lot of tutorials where is told that I have to include mysql_config to get rid of this error, but there is no help from that.
OS is Red Hat Enterprise Linux Server release 5.3 (Tikanga).
[my#server ~]$ sudo gem install mysql-2.8.1.gem --no-rdoc --no-ri -- --with-mysql-config=/usr/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql-2.8.1.gem:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile
make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX -fPIC -g -O2 -c mysql.c
gcc -shared -o mysql_api.so mysql.o -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql_api.so] Error 1
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Any suggestions?

From the error it looks as if your version of MySQL is not compatible with the version of the gem you are using.
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
If you have multiple MySQL versions installed, maybe the gem is picking up on an older version. You should verify with the MySQL gem documentation for the verison you are using whihch version of MySQL is required.

I'd recommend that you use the mysql2 gem. If you use ruby 1.8 series you should use the gem version 0.2.11 or 0.2.13 something or if you use ruby 1.9 series I'd recommend gem version 0.3.7. 0.3.X does not work for some reason on ruby 1.8.
It should work like a charm. :)

Related

ERROR: Error installing json: ERROR: Failed to build gem native extension

Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe -r ./siteconf20150301-5056-xgqsy7.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
rm -f
rm -f generator.so *.o *.bak mkmf.log .*.time
make "DESTDIR="
gcc -I. -I/usr/include/ruby-2.0.0 -I/usr/include/ruby-2.0.0/ruby/backw ard -I/usr/include/ruby-2.0.0 -I. -DJSON_GENERATOR -ggdb -O2 -pipe -Wimplicit-function-declaration -o generator.o -c generator.c
rm -f generator.so
gcc -shared -o generator.so generator.o -L. -L/usr/lib -L. -fstack-pro tector -Wl,--export-all-symbols -Wl,--enable-auto-image-base,--enable- auto-import -lruby200 -lpthread -lrt -ldl -lcrypt
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/l d: cannot find -lcrypt
collect2: error: ld returned 1 exit status
Makefile:232: recipe for target 'generator.so' failed
make: *** [generator.so] Error 1
make failed, exit code 2
Gem files will remain installed in /home/Saumyash/.gem/ruby/gems/json- 1.8.2 for inspection.
Results logged to /home/Saumyash/.gem/ruby/extensions/x86_64-cygwin/js on-1.8.2/gem_make.out
You need to install libcrypt-devel. After that it will build fine.

mysql udf error - can't install in ubuntu 12.04 64 bit

I have trouble installing the mysql udf (https://github.com/mysqludf/lib_mysqludf_sys). Here's what I'm getting:
Compiling the MySQL UDF
gcc -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so
/usr/bin/ld: /tmp/ccw6HRtN.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp/ccw6HRtN.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [install] Error 1
ERROR: You need libmysqlclient development software installed
to be able to compile this UDF, on Debian/Ubuntu just run:
apt-get install libmysqlclient15-dev
Any ideas? TIA
UPDATED:
I have already the libmysqlclient15-dev installed.
Try to recompile with -fPIC flag. It obviously hints at it:
/usr/bin/ld: /tmp/ccw6HRtN.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
I know this is an old question, however I've just had this issue using Ubuntu 16.
I solved changing the Makefile in the following way, as explained in a GitHub issue:
LIBDIR=/usr/lib/mysql/plugin
install:
gcc -DMYSQL_DYNAMIC_PLUGIN -fPIC -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o $(LIBDIR)/lib_mysqludf_sys.so

Installing bugzilla with mysql

I'm trying to install Bugzilla as part of setting up Testopia. I'm using 3.6.3 because our company site uses that and there are no plans to upgrade in the foreseeable future. I've install mysql but when I run the /usr/bin/perl install-module.pl DBD::mysql script it fails. The error message though isn't very descriptive. I've included it below:
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/home/y/lib/mysql:/lib64" /usr/bin/perl myld gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.so \
-L/home/y/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto \
/usr/bin/ld: skipping incompatible /home/y/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: * [blib/arch/auto/DBD/mysql/mysql.so] Error 1
CAPTTOFU/DBD-mysql-4.021.tar.gz
/usr/bin/make -- NOT OK
Skipping test because of notest pragma
Running make install
Make had returned bad status, install seems impossible
I don't know why libmysqlclient.so is incompatible. Is the installed version of mysql too old or is it too recent for this version of Bugzilla? The error message does not specify. Can anyone help?
this looks like this which suggest you update your operating system.
hope this could help

Tried many suggestions, how do I install mysql2 gem?

I'm trying to install a mysql2 gem on a ruby on rails app. I'm currently running Ubuntu 11.04 and this is the error I get when I run sudo gem install mysql2 or bundle install:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c client.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c mysql2_ext.c
./client.h:16:1: warning: ‘rb_thread_blocking_region’ defined but not used
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c result.c
gcc -shared -o mysql2.so client.o mysql2_ext.o result.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -lpthread -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1
Gem files will remain installed in /var/lib/gems/1.8/gems/mysql2-0.3.11 for inspection.
Results logged to /var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
I've tried installing with mysql_config, I've installed the libmysqlclient-dev and libmysql-ruby libraries, I've tried uninstalling and reinstalling mysql. None of it works. I am able to successfully install mysql gem but not mysql2.
I'm running ruby1.8 and Rails 2.3.5. Can anyone help me out?
try this:
sudo apt-get install libmysql-ruby
sudo apt-get install libmysqlclient-dev
sudo gem install mysql2
Look at this blog and others like it. But ultimately, I recommend upgrading from 11.04 to 11.10. I experienced many strange errors when running 11.04, since moving to 11.10 everything is much more stable.
If you are running CentOS/Redhat, try install the following packages (using yum):
MySQL-devel-5.5.22-1.el6.x86_64
MySQL-shared-5.5.22-1.el6.x86_64
MySQL-shared-compat-5.5.22-2.el6.x86_64

Mysql gem for Snow Leopard Install

I'm trying to get the mysql gem installed with a fresh install of Snow Leopard.
I got mysql 5.1 x86 installed from mysql site, and have tried install the mysql gem using this command.
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
getting no love.
this is my error.
gcc -I. -I/usr/local/include/ruby-1.9.1/i386-darwin10.0.0
-I/usr/local/include/ruby-1.9.1/ruby/backward
-I/usr/local/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -D_XOPEN_SOURCE=1 -O2 -g -Wall -Wno-parentheses -fno-common -pipe -fno-common -o mysql.o -c mysql.c
mysql.c: In function ‘escape_string’:
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c: In function ‘real_escape_string’:
mysql.c:434: error: lvalue required as left operand
of assignment
mysql.c:434: error:
lvalue required as left operand of
assignment
make: *** [mysql.o] Error 1
Anyone having similar problems?
ALl good,
installed 64 bit mysql, and worked ok.