不能种子数据库;由于拒绝连接而无法工作? [英] Cannot seed database; not working because of refused connection?
问题描述
当我尝试为我的应用程序做种时,出现错误:
When I try to seed my application I get the error:
无法建立连接,因为 - 目标机器主动拒绝它.- 连接(2)
No connection could be made because the - target machine actively refused it. - connect(2)
我相信原因是因为我在使用 mysql2 时遇到了问题,所以我将它与 MySQL 5.5 服务器一起卸载,然后切换到 sqlite3.我认为 mysql2 的服务器在后台运行,所以这可能是问题所在.我将如何解决这个问题?我将如何关闭 Mysql2 本地主机服务器或导致此问题的任何服务器?
I believe the reason why is because I was having issues with mysql2 so I uninstalled it along with the MySQL 5.5 Servers and then switched to sqlite3. I think the server for mysql2 is running in the background so this could be the issue. How would I fix this? How would I turn off the Mysql2 local host server or whichever server it is that's causing this issue?
我在 64 位 Windows 7 上运行.
I am running on Windows 7 64-bit.
Rails 3.0.9
SQLite3 1.3.4
谢谢.
注意:我可以很好地迁移和丢弃.
Note: I can migrate and drop fine.
config/database.yml
config/database.yml
# SQLite version 3.x
# gem install sqlite3
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
更新:
我尝试重新启动 PC 并从头开始重新制作我的应用程序,但仍然出现错误.禁用 Windows 防火墙/Comodo 防火墙并再次尝试,仍然失败.我进行了系统还原,但这也不起作用.
I tried restarting the PC and also remade my application from scratch, still get the error. Disabled Windows Firewall/Comodo Firewall and tried again, still failure. I did a System Restore but this did not work either.
这里是完整的 rake db:seed
:https://gist.github.com/1375566
已解决:
我有另一个应用程序,我在其中运行 rake db:seed
并且它运行正常,因此正如 clyfe 所接受的答案所指出的那样,问题是太阳黑子.我重新组合我的应用程序并停止添加太阳黑子,突然我收到错误:
I have another application I ran rake db:seed
in and it worked correctly, so as the accepted answer by clyfe pointed out, Sunspot was the issue. I put together again my application and stopped at adding sunspot and suddenly I got the error:
rake db:seed
(in C:/testagain)
Deleting database now...
rake aborted!
undefined method `searchable' for #<Class:0x52cdca0>
这意味着耙子正在读取我处理太阳黑子的 UserPrice 模型中的代码:
Which means the rake was reading my code inside of my UserPrice model that dealt with Sunspot:
class UserPrice < ActiveRecord::Base
# Sunspot and Websolr configuration.
#searchable do
# text :product_name do
# product.name
# end
# end
end
我对此进行了注释,并且能够正确播种.然后我继续按以下顺序使用这些命令尝试 sunspot:
I commented this out and was able to seed correctly. Then I went on to try sunspot using these commands in the following order:
rails g sunspot_rails:install
rake sunspot:solr:start (also un-comment model)
rake sunspot:reindex
rails server
rake db:seed
一切正常.
推荐答案
您正在使用 Sunspot我从你的要点中看到的索引和搜索 https://gist.github.com/1375566
确保在播种前已启动 Solr 服务器.
You are using Sunspot for indexing and search as I see from your gist https://gist.github.com/1375566
Make sure that the Solr server is started before you seed.
会发生什么:
- 当模型保存时
- 它尝试将数据发送到 Solr 服务器以进行索引
- 但是无法连接
可能的问题:
- Solr 服务器未启动
/config/sunspot.yml
中未正确配置 Sunspot Solr 连接- 被防火墙阻止的端口
如果您还没有启动 Solr 服务器实例,您可以使用以下 rake 命令启动 Sunspot 捆绑的 Solr 服务器:
If you haven't started a Solr server instance already, you can start the Sunspot-bundled Solr server with the following rake command:
rake sunspot:solr:start
这篇关于不能种子数据库;由于拒绝连接而无法工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!