Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.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
Rails无法连接到mySQL_Mysql_Ruby On Rails_Apache - Fatal编程技术网

Rails无法连接到mySQL

Rails无法连接到mySQL,mysql,ruby-on-rails,apache,Mysql,Ruby On Rails,Apache,我一直在尝试通过PhusionPassenger使用RubyonRails和mySQL建立Apache服务器。我有Apache v2.2.3、Passenger v3.0.13、Ruby v1.9.3、Rails v3.2.6和mySQL v5.0.95 早些时候,由于Javascript运行时不正确,我遇到了一些问题,但我通过安装execjs和therubyracer解决了这些问题。我成功地用SQLite创建了这个网站,但我需要使用mySQL 现在,我使用命令rails new myProje

我一直在尝试通过PhusionPassenger使用RubyonRails和mySQL建立Apache服务器。我有Apache v2.2.3、Passenger v3.0.13、Ruby v1.9.3、Rails v3.2.6和mySQL v5.0.95

早些时候,由于Javascript运行时不正确,我遇到了一些问题,但我通过安装execjs和therubyracer解决了这些问题。我成功地用SQLite创建了这个网站,但我需要使用mySQL

现在,我使用命令rails new myProject-d mysql创建了一个新项目,并将适当的gem添加到我的Gemfile中,即gem'mysql2','0.3.11';gem‘execjs’;和宝石“therubyracer”

My database.yml文件如下所示:测试部件和生产部件的名称不同:

development:
  adapter: mysql2
  encoding: utf8
  database: myProject_development
  pool: 5
  username: root
  password:
  host: localhost
  socket: /var/lib/mysql/mysql.sock
现在,问题还没有立即显现出来。从终端,我找不到任何问题,即rake db:创建运行正确,脚手架上没有出现错误等,但当我访问网站时,乘客显示以下错误:

无法启动Ruby Rack应用程序 在任何源Bundler::GemNotFound中都找不到mysql2-0.3.11 没有一个网页出现。那么,我的错在哪里?我相信我的Gemfile是正确的,我的database.yml似乎已经更新了,我可以从终端访问mySQL,并且我能够在SQLite中运行该网站。如有任何建议,将不胜感激

编辑:我的文件:

source 'https://rubygems.org'

gem 'rails', '3.2.6'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2','0.3.11'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server                     
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

gem 'execjs'
gem 'therubyracer'
编辑:捆绑列表的输出:

Gems included by the bundle:
  * actionmailer (3.2.6)
  * actionpack (3.2.6)
  * activemodel (3.2.6)
  * activerecord (3.2.6)
  * activeresource (3.2.6)
  * activesupport (3.2.6)
  * arel (3.0.2)
  * builder (3.0.0)
  * bundler (1.1.4)
  * coffee-rails (3.2.2)
  * coffee-script (2.2.0)
  * coffee-script-source (1.3.3)
  * erubis (2.7.0)
  * execjs (1.4.0)
  * hike (1.2.1)
  * i18n (0.6.0)
  * journey (1.0.4)
  * jquery-rails (2.0.2)
  * json (1.7.3)
  * libv8 (3.3.10.4)
  * mail (2.4.4)
  * mime-types (1.19)
  * multi_json (1.3.6)
  * mysql2 (0.3.11)
  * polyglot (0.3.3)
  * rack (1.4.1)
  * rack-cache (1.2)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.2.6)
  * railties (3.2.6)
  * rake (0.9.2.2)
  * rdoc (3.12)
  * sass (3.1.20)
  * sass-rails (3.2.5)
  * sprockets (2.1.3)
  * therubyracer (0.10.1)
  * thor (0.15.4)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.33)
  * uglifier (1.2.6)

编辑:哦,顺便说一下,我正在使用CentOS 5.8。

将以下内容添加到您的文件中:

gem 'mysql2'
下一轮

bundle install

添加mysql2 gem后是否运行了bundle?尝试执行bundle updateI将我的Gemfile添加到原始帖子中。而且,谢谢,但我在每次编辑之后都会运行bundle update或bundle install以及服务httpd重启。我看到了我在运行bundle时安装的所有gems,它显示了正确的mysql2 0.3.11版本。它包含mysql2 0.3.11。我不知道你还想找什么,但以防万一,我已经把它附加到我的帖子里了。谢谢