Rake db error: ERROR 1102 (42000) at line 1: Incorrect database name [nil]
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 conso开发者_运维问答les to expose some information? Perhaps one that can verify it's connecting to the database, or if not what the problem is?
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
#Add this to config/environment.rb at the top
require 'yaml'
YAML::ENGINE.yamler= 'syck'
That did the trick and solved this issue. Hope it helps.
精彩评论