Gem mysql连接错误

时间:2017-06-01 17:52:14

标签: mysql ruby-on-rails ruby rubygems

我在尝试使用gem'mysql'连接到DB

时遇到错误
/home/sajeesh/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': libperconaserverclient.so.18: cannot open shared object file: No such file or directory - /home/sajeesh/.rvm/gems/ruby-2.1.4@global/gems/mysql-2.9.1/lib/mysql/mysql_api.so (LoadError)
    from /home/sajeesh/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/sajeesh/.rvm/gems/ruby-2.1.4@global/gems/mysql-2.9.1/lib/mysql.rb:6:in `rescue in <top (required)>'
    from /home/sajeesh/.rvm/gems/ruby-2.1.4@global/gems/mysql-2.9.1/lib/mysql.rb:2:in `<top (required)>'
    from /home/sajeesh/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:133:in `require'
    from /home/sajeesh/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
    from /home/sajeesh/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:40:in `require'
    from ./mysql.rb:7:in `<main>'
-bash-4.1$ 

-bash-4.1$ ruby -v
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]
-bash-4.1$ gem list | grep mysql
mysql (2.9.1)
-bash-4.1$ 

有没有可行的解决方法;我已经多次卸载并安装了mysql gem,并且还尝试了更高版本的ruby;似乎什么都没有用。请帮我解决。

1 个答案:

答案 0 :(得分:0)

确保使用mysql2 gem然后捆绑并确保您的数据库配置文件具有正确的连接配置。