简体   繁体   English

MySQL Rails迁移错误:“重命名schema_migration时出错(错误号:-1)”

[英]MySQL Rails migration error: “Error on rename of schema_migration (errno: -1)”

I'm a PHP dev and I'm new to Rails but have been getting on pretty well, everything seems pretty straightforward. 我是一个PHP开发人员,我是Rails的新手,但是一直都很顺利,一切看起来都非常简单。 However, up until this morning I have been using SQLite and decided to move what I'm building to MySQL. 然而,直到今天早上我一直在使用SQLite并决定将我正在构建的内容移动到MySQL。 rake db:create works perfectly, but when I attempt to rake db:migrate I get the following error: rake db:create完美运行,但是当我尝试rake db:migrate时,我收到以下错误:

rake aborted! 耙子流产了! Mysql::Error: Error on rename of './test_development/schema_migrations' to './test_development/#sql2-c7b-c' (errno: -1): CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations ( version ) Mysql :: Error:将'./test_development/schema_migrations'重命名为'./test_development/#sql2-c7b-c'时出错(错误号:-1):CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrationsversion

Thinking that it might be an error in my migration scripts, I created a clean rails project with the simplest of tables and get the same error. 考虑到我的迁移脚本中可能存在错误,我使用最简单的表创建了一个干净的rails项目并获得相同的错误。 So, I reinstalled MySQL and the mysql gem to ensure it wasn't something ill with either of those and I'm still having no luck. 所以,我重新安装了MySQL和mysql gem,以确保它们不会出现任何问题,而我仍然没有运气。 Here's the versions I'm running: 这是我正在运行的版本:

  • Rails 2.3.4 Rails 2.3.4
  • Ruby 1.8.6 Ruby 1.8.6
  • MySQL 5.1.40 MySQL 5.1.40
  • MySQL Gem 2.8.1 MySQL Gem 2.8.1

I have a feeling it could be InnoDB related, as I've had problems with that engine before on this box. 我觉得它可能与InnoDB有关,因为我在这个盒子之前遇到过这个引擎的问题。 But, if anyone can help me out I'd be extremely grateful as it's stopping me progressing. 但是,如果有人能帮助我,我会非常感激,因为它阻止了我的进步。

Thanks, 谢谢,

Kieran 基兰

UPDATE: As requested by Phil here's the results of: 更新:根据菲尔的要求,结果如下:

SHOW ENGINE INNODB STATUS 显示发动机创新状态

and

SHOW VARIABLES LIKE 'innodb%' 显示变量像'innodb%'

You've got the innodb_force_recovery option set to 6. This was presumably changed from the default 0 to fix an earlier problem. 您已将innodb_force_recovery选项设置为6.这可能是从默认值0更改为修复先前的问题。 InnoDB won't allow anything much other than SELECT , CREATE TABLE and DROP TABLE in this mode. 在此模式下,InnoDB不允许除SELECTCREATE TABLEDROP TABLE之外的任何内容。

Try shutting down MySQL and then editing your my.cnf file. 尝试关闭MySQL,然后编辑my.cnf文件。 Set innodb_force_recovery to 0 (or remove the option) and then restart MySQL. 将innodb_force_recovery设置为0(或删除该选项),然后重新启动MySQL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM