$ bundle exec rake db:reset命令raise不能删除db/development.sqlite3

Wow*_*Bow 20 ruby sqlite ruby-on-rails ruby-on-rails-3 railstutorial.org

我试着运行$ bundle exec rake db:reset并在控制台上找到以下内容

Couldn't drop db/development.sqlite3 : #<Errno::EACCES: Permission denied - c:/sample_app/db/development.sqlite3>
db/development.sqlite3 already exists
-- create_table("users", {:force=>true})
   -> 0.3940s
-- add_index("users", ["email"], {:name=>"index_users_on_email", :unique=>true})

   -> 0.1280s
-- initialize_schema_migrations_table()
   -> 0.0010s
-- assume_migrated_upto_version(20120419034627, ["c:/sample_app/db/migrate
"])
   -> 0.0040s
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

编辑我正在关注一个教程,它告诉我运行上面的命令来安全地删除数据库中的所有数据.我也在使用管理员帐户.

hta*_*ata 41

当你这样做db:reset,它的运行db:dropdb:setup顺序.您的错误消息表明db/development.sqlite无法删除.

如果你在Windows上,也许你需要停止你的Rails服务器和控制台.否则,找出阻止文件被删除的内容.这可能是许可问题.重启也可以解决问题.

  • 有同样的问题,我需要停止rails服务器.谢谢! (3认同)
  • 我重新启动了所有使用rails资源的东西,现在一切都很好. (2认同)