Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RubyonRails可以';t使用MySQL创建/使用应用程序_Mysql_Ruby On Rails_Ruby - Fatal编程技术网

RubyonRails可以';t使用MySQL创建/使用应用程序

RubyonRails可以';t使用MySQL创建/使用应用程序,mysql,ruby-on-rails,ruby,Mysql,Ruby On Rails,Ruby,我正在尝试学习Rails,但无法使用MySQL创建项目。 我使用MAMP在OSX10.9上使用PHP进行开发,所以我尝试配置Rails以运行它,但我不能。如果有人对这里发生的事情有一些指导或线索,我将非常感激 如果我必须在没有MAMP的情况下使用apache和mysql来解决这个问题,那没关系,但只要告诉我是否真的有必要 williamcalderipe@~/Projects/rails$ rails new mysql_app_test -d mysql [...] Fetching ge

我正在尝试学习Rails,但无法使用MySQL创建项目。 我使用MAMP在OSX10.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.
这是我的配置文件/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不见了我安装了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选择--instal
并尝试安装命令行工具时,会发生这种情况:

这是一个非常有用的博客,用于在OS X上安装/检查Mysql


您的机器上安装了mysql服务器吗?是的,我正在使用MAMP for mysql和Apache服务器!非常感谢。我将安装一个独立的mysql服务器,我希望这不会与我的MAMP mysql服务器冲突。好的,你重启了mysql服务器吗?是的,我重启了。。我正在弄清楚MAMP mysql opt dir在哪里作为参数传递给gem安装mysql——使用opt dir