gpt4 book ai didi

mysql - 在rails 3.1RC4上使用mysql

转载 作者:行者123 更新时间:2023-11-29 14:45:37 25 4
gpt4 key购买 nike

我无法让 Rails 3.1RC4 与 mysql 一起使用...?

我刚刚制作了一个新的测试应用程序,但它也失败了?

我做了:rails new blog2 -d mysql

然后在我的 gemfile 中:gem 'mysql2'

在database.yml文件中:

development:
adapter: mysql2
encoding: utf8
reconnect: false
database: blog2_development
pool: 5
username: root
password: password
socket: /tmp/mysql.sock

现在当我运行 Rails 时

我收到以下错误:

MacBook-van-T-Boeree:blog2 tboeree$ rails s
/Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.6/lib/mysql2.rb:9:in `require': dlopen(/Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.6/lib/mysql2/mysql2.bundle
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.6/lib/mysql2.rb:9:in `<top (required)>'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
from /Users/tboeree/Dropbox/rails_projects/blog2/config/application.rb:7:in `<top (required)>'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands.rb:52:in `require'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands.rb:52:in `block in <top (required)>'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `tap'
from /Users/tboeree/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

捆绑安装:

MacBook-van-T-Boeree:blog2 tboeree$ bundle install
Using rake (0.9.2)
Using multi_json (1.0.3)
Using activesupport (3.1.0.rc4)
Using bcrypt-ruby (2.1.4)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.0.rc4)
Using erubis (2.7.0)
Using rack (1.3.2)
Using rack-cache (1.0.2)
Using rack-mount (0.8.2)
Using rack-test (0.6.1)
Using hike (1.2.0)
Using tilt (1.3.2)
Using sprockets (2.0.0.beta.13)
Using tzinfo (0.3.29)
Using actionpack (3.1.0.rc4)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.0.rc4)
Using arel (2.1.4)
Using activerecord (3.1.0.rc4)
Using activeresource (3.1.0.rc4)
Using ansi (1.3.0)
Using bundler (1.0.15)
Using coffee-script-source (1.1.2)
Using execjs (1.2.4)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.9.1)
Using thor (0.14.6)
Using railties (3.1.0.rc4)
Using jquery-rails (1.0.12)
Using mysql2 (0.3.6)
Using rails (3.1.0.rc4)
Using sass (3.1.7)
Using sass-rails (3.1.0.rc.5)
Using turn (0.8.2)
Using uglifier (1.0.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

我正在 macbook 上工作,当我输入 mysql --version 时,我安装了 32 位版本的 mysql --version 我看到这个版本:mysql Ver 14.14 Distrib 5.5.15, for osx10.6 (i386) using readline 5.1

服务器已启动...

有什么建议吗?问候,泰斯

最佳答案

查看其他答案后,您需要将 mysql gem 指向您安装的库

sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

是魔法命令

关于mysql - 在rails 3.1RC4上使用mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7011452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com