编辑:问题已解决,感谢这篇论坛帖子:http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407。谢谢大家!
我开始学习 RoR 并尝试使用 rake db:migrate
,但一直遇到同样的错误。我可以使用 C:\dev\railslist>mysql -u root railslist_development -p
连接到 MySQL 数据库。
rake db:migrate --trace
会产生以下结果:
C:\dev\railslist>rake db:migrate --trace
(in C:/dev/railslist)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
Mysql::Error: query: not connected: CREATE TABLE 'schema_migrations' ('version'
varchar(255) NOT NULL) ENGINE=InnoDB
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/abstract_adapter.rb:219:in 'rescue in log'
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/abstract_adapter.rb:202:in 'log'
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/mysql_adapter.rb:323:in 'execute'
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/abstract/schema_statements.rb:114:in 'create_table'
...
我的 database.yml 文件如下:
development:
adapter: mysql
database: railslist_development
username: root
password: **********
host: localhost
...
编辑: 对不起,我搞混了... 我可以使用mysql connect localhost
连接到MySQL数据库 - 它会生成一长串命令和变量。同时,如果我输入mysql -h localhost -u root -p
,我也可以登录到MySQL提示符中。所以要澄清一下:我可以通过命令行连接到MySQL数据库,但是在RoR Rake中会出现错误。