繁体   English   中英

Ruby on Rails无法使用MySQL创建/使用应用

[英]Ruby on Rails can't create/use an app using MySQL

我正在尝试学习Rails,但是无法使用MySQL创建项目。 我使用MAMP在OS X 10.9上用PHP进行开发,所以我试图配置Rails使其与它一起运行,但是我不能。 如果有人有一些教程或线索,在这里会发生什么,我将非常感激。

如果我必须在不使用MAMP的情况下使用apache和mysql来解决此问题,但是请告诉我是否确实有必要!

williamcalderipe@~/Projects/rails$ rails new mysql_app_test -d mysql

[...]

Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.2)
Using bundler (1.5.3)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.2)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.3)
Using jquery-rails (3.1.0)
Using json (1.8.1)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing.  please check your installation of mysql and try again.
-----
*** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/
    --with-mysql-config
    --without-mysql-config

extconf failed, exit code 1

Gem files will remain installed in /Users/williamcalderipe/.rvm/gems/ruby-2.0.0-p353/gems/mysql2-0.3.15 for inspection.
Results logged to /Users/williamcalderipe/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.15/gem_make.out
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.

这是我的config / database.yml

development:
adapter: mysql2
encoding: utf8
database: mysql_app_test_development
pool: 5
username: root
password: root
host: localhost
socket: /Applications/MAMP/tmp/mysql/mysql.sock

当我运行rails s

Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.

好吧。所以缺少mysql2,我没有用gem install mysql2

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing.  please check your installation of mysql and try again.
-----
*** 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.

Provided configuration options:
[SAME CONFIGURATIONS AS THE FIRST CODE POSTED]

我的XCode版本是5.0.2(5A3005),所以当我执行xcode-select --instal并尝试安装命令行工具时,会发生这种情况: 在此处输入图片说明

这是在OS X上安装/检查Mysql的非常有用的博客。

http://blog.mclaughlinsoftware.com/2011/02/10/mac-os-x-mysql-install/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM