0

我从官方网站安装了 mysql 5.1.61。它已被编译和安装,但现在当我尝试运行简单rake db:migrate时,它显示这样的错误

Connecting to {:password=>nil, :encoding=>"utf8", :database=>"mnemosyne_spec", :host=>"localhost", :username=>"root", :adapter=>"mysql2"}
rake aborted!
LoadError: dlsym(0x7faaf9048bf0, Init_mysql2): symbol not found - /Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

Tasks: TOP => db:migrate

完整跟踪:

** Invoke db:migrate (first_time)
** Execute db:migrate
Connecting to {:password=>nil, :encoding=>"utf8", :database=>"mnemosyne_spec", :host=>"localhost", :username=>"root", :adapter=>"mysql2"}
rake aborted!
LoadError: dlsym(0x7fafa1d30510, Init_mysql2): symbol not found - /Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/mysql2-0.3.11/lib/mysql2.rb:9
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/adapters/mysql2.rb:1:in `require'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/adapters/mysql2.rb:1
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:379:in `k_require'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:379:in `tsk_require'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:100:in `check_requiring_thread'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:97:in `synchronize'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:97:in `check_requiring_thread'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:379:in `tsk_require'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/database/connecting.rb:25:in `adapter_class'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/database/connecting.rb:67:in `connect'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/gems/sequel-3.39.0/lib/sequel/core.rb:147:in `connect'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/lib/mnemosyne.rb:52:in `db_connect!'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/lib/mnemosyne.rb:32:in `configure'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/lib/mnemosyne.rb:25:in `initialize!'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/lib/mnemosyne/database_tasks.rb:21:in `initialize'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/lib/mnemosyne/database_tasks.rb:83:in `initialize'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/Rakefile:63:in `new'
/Users/serg/rails_projects_terminal/brandspotter/mnemosyne/Rakefile:63
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/Users/serg/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/bin/rake:33
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/bin/rake:19:in `load'
/Users/serg/.rvm/gems/ruby-1.8.7-p370@global/bin/rake:19
/Users/serg/.rvm/gems/ruby-1.8.7-p370@mnemosyne/bin/ruby_noexec_wrapper:14
Tasks: TOP => db:migrate

我试图重新安装 ruby​​ 和 gems 并没有改变。我能做些什么来解决这个问题?

我的资料:

Mac OS X 10.8.2 Mountain Lion
Xcode 4.5.1
osx-gcc-installer
Mysql  Ver 14.14 Distrib 5.1.61, for apple-darwin10.3.0 (i386) using readline 5.1
RVM 1.16.10

PS我从自制软件安装mysql没有这样的问题。

4

1 回答 1

0

我创立了解决方案!

问题出在 MySQL 安装中。它是 x86,对于 Mac OS X 10.7 + 是不正确的。

1)所以,首先我们应该删除旧版本的 MySQL:

$ sudo rm /usr/local/mysql
$ sudo rm -rf /usr/local/mysql*
$ sudo rm -rf /Library/StartupItems/MySQLCOM
$ sudo rm -rf /Library/PreferencePanes/My*
$ sudo rm -rf /Library/Receipts/mysql*
$ sudo rm -rf /Library/Receipts/MySQL*
$ sudo rm -rf /var/db/receipts/com.mysql.*

1.1)在那次运行之后

$ nano /etc/hostconfig

并删除线

MYSQLCOM=-YES-

2)为了确保一切正常,您至少可以删除 mysql gem:

$ gem uninstall mysql2

或者您可以通过 rvm 删除 gemset 中的所有 gem:

$ rvm gemset empty your-gemset-name

3)然后安装x64 MySQL版本

4)并通过捆绑器安装所有缺少的宝石:

$ bundle
于 2012-10-10T12:21:14.950 回答