Trouble installing mysql2 gem, libmysqlclient.so.15 Load Error
veHi,
I'm trying t开发者_开发技巧o install Rails 3.0 with Ruby 1.9.2. on a Linux box. I'm behind a firewall and do not have root access on my machine so I'm trying to build everything in my home directory. I don't have access to apt-get or yum - I have to build everything from source (except for gems).
I've successfully compiled and built Ruby, Rails, and MySQL. My problem is that rails can't find the libmysqlclient.so.15 library. I've tried every conceivable option to "gem install mysql2" to tell it where the library is, with no luck. Note that if I have the local mysql/lib directory in my LD_LIBRARY_PATH, everything works. I just can't figure out how to tell mysql2 where the library is. Can someone help?
Thanks,
Stan McFarland
I'm sure you must also install the mysql-dev packages.
The file libmysqlclient_r.so.15 is in the mysql shared-compat package. The example below is using a specific mirror and it's for 32 bit generic linux. You can find the right package for your platform at http://dev.mysql.com/downloads/mysql/
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-shared-compat-5.5.13-1.linux2.6.i386.rpm/from/http://mysql.mirrors.pair.com/
$ yum install --nogpgcheck MySQL-shared-compat-5.5.13-1.linux2.6.i386.rpm
That default installation path is the same that the mysql2 gem used.
On OS X, I know I always have to update the library location in the gem manually. That same trick should work fine on linux. Adjust names and paths to match your platform:
$ sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
精彩评论