Heroku rake db:结构:用cleardb加载找不到’mysql’

我正在尝试在heroku dyno上安装Sharetribe的实例。 我正在尝试创建数据库。 我首先尝试了rake db:migrate,它适用于大多数迁移,但在其中一个迁移时失败了。

我被建议使用rake db:structure:load,所以我尝试了,我从Heroku得到一个错误,说mysql需要添加到PATH变量。 为什么会这样,我该如何解决? 我不确定它为什么会在db:schema:load和db:structure:load但不在db:migrate上发生。

带有错误消息的完整堆栈跟踪是:

rake aborted! failed to execute: mysqlPlease check the output above for any errors and make sure that `mysql` is installed in your PATH and has proper permissions. /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:148:in `run_cmd' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:72:in `structure_load' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:189:in `structure_load' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:222:in `load_schema_for' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:236:in `block in load_schema_current' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:235:in `load_schema_current' /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:293:in `block (3 levels) in ' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in ' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors' /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `' /app/bin/bundle:3:in `load' /app/bin/bundle:3:in `' Tasks: TOP => db:structure:load (See full trace by running task with --trace) 

谢谢!

如果你需要运行heroku run bundle exec rake db:structure:load比你需要安装mysql客户端。 要安装其他软件包,您需要添加Buildpacks (官方或基于社区)。

对于mysql,我成功使用了https://github.com/din-co/heroku-buildpack-mysql

 heroku buildpacks:add --index 1 https://github.com/din-co/heroku-buildpack-mysql git commit --amend --allow-empty --no-edit git push heroku -f 

Heroku不支持mysql ,你需要在生产块中的gemfile中使用pg gem。 请阅读Heroku上的Rails 5.x入门

Interesting Posts