Rake 数据库错误:第 1 行错误 1102 (42000):数据库名称不正确 [nil]
我收到以下错误:
$ rake db:drop
(在 D:/Repository/MyApp 中)
~ [datamapper] 设置“开发”环境:
~ [datamapper] 在 mysql 上设置:默认存储库:''
第 1 行出现错误 1102 (42000):数据库名称 '' 不正确
以下是我的 database.yml 文件:
defaults: &defaults
adapter: mysql
encoding: utf8
reconnect: false
pool: 5
username: dbuser
password: ******
development:
database: myapp_development
host: 127.0.0.1
<<: *defaults
test:
database: myapp_test
host: 127.0.0.1:3306
<<: *defaults
production:
database: myapp_production
host: mysql.myapp.com
<<: *defaults
我正在 Windows 平台上运行 mysql 5.5 服务器,使用 Ruby 1.9.2 和 Rails 3,并且配置了服务器使用正确的数据库、用户和密码。我正在使用数据映射器。这适用于我们的实时网站,但不适用于我的本地网站。运行 'rails dbconsole' 会产生 "ruby192installationpath/dbconsole.rb:75: in 'exec': can't conversion nil into String (TypeError)。
以前有人遇到过这个问题吗?关于如何诊断或纠正它有什么建议吗?或者也许是一个可以从终端、rails 或 rake 控制台运行的简单诊断命令来公开一些信息?也许可以验证它是否连接到数据库,或者如果不是,问题是什么?
I am getting the following error:
$ rake db:drop
(in D:/Repository/MyApp)
~ [datamapper] Setting up the "development" environment:
~ [datamapper] Setting up :default repository: '' on mysql
ERROR 1102 (42000) at line 1: Incorrect database name ''
The following is my database.yml file:
defaults: &defaults
adapter: mysql
encoding: utf8
reconnect: false
pool: 5
username: dbuser
password: ******
development:
database: myapp_development
host: 127.0.0.1
<<: *defaults
test:
database: myapp_test
host: 127.0.0.1:3306
<<: *defaults
production:
database: myapp_production
host: mysql.myapp.com
<<: *defaults
I'm running a mysql 5.5 server on a Windows platform, with Ruby 1.9.2 and Rails 3, and the server is configured with the proper databases, user and password. I'm using datamapper. This works on our live site, but not on my local site. Running 'rails dbconsole' produces "ruby192installationpath/dbconsole.rb:75: in 'exec': can't convert nil into String (TypeError).
Has anyone run into this problem before? Any suggestions on how to diagnose or correct it? Or perhaps a simple diagnostic command that can be run from the terminal, rails or rake consoles to expose some information? Perhaps one that can verify it's connecting to the database, or if not what the problem is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的错误,并通过另一篇文章发现它实际上是由 YAML 解析错误引起的。
这让我记住,当使用 Ruby 1.9.2 设置 Mongoid 时,我必须在 config/environment.rb 中包含以下内容
,这解决了这个问题。
希望有帮助。
I was experiencing that same error and found through another post that it was actually caused by a YAML parsing error.
That made remember that when setting up Mongoid with Ruby 1.9.2, I had to include the following in config/environment.rb
That did the trick and solved this issue.
Hope it helps.