2013-08-20 119 views
2

我不知道如何安裝mysql2。爲什麼我不能在Ruby On Rails上安裝mysql2?

我使用:

  • Ruby on Rails的3.2.14
  • 的Ruby 2.0.0
  • 的Mac OS X 10.9( 「小牛」)

Installing mysql2 (0.3.13) 

An error occurred while installing mysql2 (0.3.13), and Bundler cannot continue. 
Make sure that `gem install mysql2 -v '0.3.13'` succeeds before bundling. 

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 

*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of necessary 
libraries and/or headers. Check the mkmf.log file for more details. You may 
need configuration options. 


Gem files will remain installed in /Users/kimingi/.bundler/tmp/1983/gems/mysql2-0.3.13 for inspection. 
Results logged to /Users/kimingi/.bundler/tmp/1983/gems/mysql2-0.3.13/ext/mysql2/gem_make.out 

An error occurred while installing mysql2 (0.3.13), and Bundler cannot continue. 
Make sure that `gem install mysql2 -v '0.3.13'` succeeds before bundling. 

ERROR: Error installing mysql2: 
    ERROR: Failed to build gem native extension. 
+1

您是否首先安裝libmysqlclient-dev? – Bigxiang

+0

生活在操作系統版本的最前沿的問題之一是您繼承移植現有代碼以處理未知/新代碼庫的問題。安裝人員測試已知版本,並經常嘔吐與未知的版本。 –

+0

你見過這個http://stackoverflow.com/questions/5409761/installing-mysql2-gem-for-ruby-on-rails-with-mac-osx-10-6 –

回答

6

您需要在本地安裝mysql。由於您使用的是OS X,因此您可以使用Homebrew

# to Install homebrew 
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" 

# to install mysql through homebrew 
brew install mysql 
+0

你可能會添加更多關於如何安裝的信息自制軟件,因爲它不是Mac OS安裝的常規部分。 –

0

我跑到同樣的問題。要解決此問題,請打開命令提示符。去你的應用程序文件夾。然後輸入:gem install mysql2 -v 0.3.11這個版本工作的很好。