我正在尝试将现有数据库导入到我们正在开发的新rails应用程序中。我使用rake db:schema dump
成功转储数据库的模式。每当我尝试使用rake db:data:dump
转储数据时,rake将使用以下输出中止:
rake db:data:dump --trace
** Invoke db:data:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:data:dump
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key LIMIT 1000 OFFSET 0' at line 1: SELECT * FROM `hypqd_akeeba_common` ORDER BY key LIMIT 1000 OFFSET 0
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:297:in `query'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:297:in `block in execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:464:in `block in log'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0.beta4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:458:in `log'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:297:in `execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/mysql2_adapter.rb:225:in `execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/mysql2_adapter.rb:229:in `exec_query'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:340:in `select'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:184:in `block in each_table_page'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:182:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:182:in `each_table_page'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/yaml_db.rb:47:in `dump_table_records'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:167:in `dump_table'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:150:in `block in dump'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:148:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:148:in `dump'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:14:in `dump'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/tasks/yaml_db_tasks.rake:21:in `block (3 levels) in <top (required)>'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/awernick/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/rake:23:in `load'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/rake:23:in `<main>'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key LIMIT 1000 OFFSET 0' at line 1
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:297:in `query'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:297:in `block in execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:464:in `block in log'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0.beta4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:458:in `log'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:297:in `execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/mysql2_adapter.rb:225:in `execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/mysql2_adapter.rb:229:in `exec_query'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:340:in `select'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:184:in `block in each_table_page'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:182:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:182:in `each_table_page'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/yaml_db.rb:47:in `dump_table_records'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:167:in `dump_table'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:150:in `block in dump'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:148:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:148:in `dump'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/serialization_helper.rb:14:in `dump'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/yaml_db-0.3.0/lib/tasks/yaml_db_tasks.rake:21:in `block (3 levels) in <top (required)>'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/awernick/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/awernick/.rvm/gems/ruby-2.1.5/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/rake:23:in `load'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/rake:23:in `<main>'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
/Users/awernick/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:data:dump
我已检查过我的架构,但找不到与语法错误key LIMIT 1000 OFFSET 0' at line 1: SELECT * FROM ``hypqd_akeeba_common`` ORDER BY key LIMIT 1000 OFFSET 0
是什么导致佣金中止?
答案 0 :(得分:0)
我能够解决问题。这个问题与rake甚至mysql无关。我的数据库没有从phpmyadmin原始数据库中正确转储。在减少数据库后,一切正常。