简体   繁体   English

JRuby,Rails 2.3.5,MySQL数据库未使用rake db:create:all创建

[英]JRuby, Rails 2.3.5, MySQL Databases not being created with rake db:create:all

Basic information: 基本信息:

Ruby version : 1.8.7
JRuby version: 1.5.3 
Rails version: 2.3.5
Mysql version: Ver 14.14 Distrib 5.1.48, for apple-darwin10.3.0 (i386) using readline 5.1

I've been having a hell of a time trying to get JRuby, Rails, and MySQL to play nicely together. 我一直在努力让JRuby,Rails和MySQL很好地玩在一起。 I've come to a dead end and now need some help. 我走到了尽头,现在需要一些帮助。

I have installed what I believe to be the correct gems to allow JRoR to talk with MySQL. 我已经安装了我认为是正确的宝石,以允许JRoR与MySQL对话。 The list of gems I have installed are below. 我已安装的宝石列表如下。 How I am trying to create a JRoR + MySQL app is like so: 我如何尝试创建JRoR + MySQL应用程序,如下所示:

$ jruby -S rails -d mysql app_name
$ cd app_name

Open up Textmate and configure config/database.yml by changing all adapters from "mysql" to "jdbcmysql". 通过将所有适配器从“ mysql”更改为“ jdbcmysql”,打开Textmate并配置config / database.yml。

Back in Terminal: 返回终端:

$ jruby -S script/generate scaffold post title:string content:text
$ rake db:create:all

At this point, rake doesn't spit out anything to tell me the databases were created. 此时,rake不会吐出任何东西来告诉我数据库已创建。 Here's the result of trying to run my migration: 这是尝试运行迁移的结果:

$ rake db:migrate

rake aborted!
The driver encountered an unknown error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'app_name_development'

I have no idea what I'm doing wrong and would greatly appreciate help. 我不知道我在做什么错,非常感谢您的帮助。

Here's my current gem list: 这是我当前的宝石清单:

$ jruby -S gem list

* LOCAL GEMS * *当地的宝石*

abstract (1.0.0)
actionmailer (3.0.0, 2.3.5)
actionpack (3.0.0, 2.3.5)
activemodel (3.0.0)
activerecord (3.0.0, 2.3.5)
activerecord-jdbc-adapter (1.0.2, 0.9.7)
activerecord-jdbcmysql-adapter (1.0.2, 0.9.7)
activerecord-jdbcsqlite3-adapter (0.9.7)
activeresource (3.0.0, 2.3.5)
activesupport (3.0.0, 2.3.10, 2.3.5)
after_commit (1.0.8)
arel (1.0.1)
bouncy-castle-java (1.5.0145.2)
builder (2.1.2)
bundler (1.0.2)
columnize (0.3.1)
erubis (2.6.6)
gem_plugin (0.2.3)
i18n (0.4.1)
jdbc-mysql (5.0.4)
jdbc-sqlite3 (3.6.3.054)
jruby-jars (1.5.3)
jruby-openssl (0.7.2)
jruby-rack (1.0.3)
mail (2.2.7)
mime-types (1.16)
mongrel (1.1.5)
polyglot (0.3.1)
rack (1.2.1, 1.0.1)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (2.3.5)
railties (3.0.0)
rake (0.8.7)
riddle (1.1.0)
rspec (1.3.0)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3.2)
rubyzip (0.9.4)
sources (0.0.1)
thinking-sphinx (1.3.20)
thor (0.14.3)
treetop (1.4.8)
tzinfo (0.3.23)
warbler (1.2.1)
will_paginate (2.3.15)

You shouldn't need to change the database name to jdbcmysql . 您不需要将数据库名称更改为jdbcmysql In fact, doing this defeats db:create(:all) . 实际上,这样做会使db:create(:all)失败。

http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter/ http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter/

I noticed the "Unknown database 'app_name_development'" error. 我注意到“未知数据库'app_name_development'”错误。 Is app_name_development really the name of your database in database.yml? app_name_development确实是您在database.yml中的数据库名称吗? Just checking, because if not, that would be very interesting. 只是检查一下,因为如果没有,那将非常有趣。

I assume you're not connecting to MySQL with the root account. 我假设您没有使用root帐户连接到MySQL。 If that's true, does the user you are connecting with have permissions to create the database app_name_development? 如果是这样,您所连接的用户是否具有创建数据库app_name_development的权限? By default, only root can create databases. 默认情况下,只有root才能创建数据库。 You can grant your user permission with something like this: 您可以通过以下方式授予用户权限:

GRANT CREATE on app_name_development.* to 'user'@'host';

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

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