【问题标题】:Load a series of sql files through capistrano通过capistrano加载一系列sql文件
【发布时间】:2012-01-19 11:43:21
【问题描述】:

我在尝试通过我们的 capistrano 配方为我们的测试环境加载一系列 sql 文件时遇到问题。

这是我想出的:

  desc "Empty database and play sql scripts for fresh db structure"
  task :mysqlrestore, :roles => :app do 

  run "find #{current_release}/migration/ -name '*.sql' -print0 | xargs -0 -I file mysql -hlocalhost -u#{db_username} -p#{db_password} #{db_database} < file"

我的 capistrano 控制台输出:

失败:“sh -c 'find /home/toolbox/www/staging/releases/20120119111819/migration/ -name '\''*.sql'\'' -print0 | xargs -0 -I file mysql - staging.env.com 上的 hlocalhost -uuser -ppassword DBNAME

我哪里错了?

【问题讨论】:

  • 我认为您在 -u 和用户名、-p 和密码等之间缺少空格。

标签: mysql bash capistrano


【解决方案1】:

只需从运行命令中删除单引号,我就能够从 bash 执行命令。

 run "find #{current_release}/migration/ -name *.sql -print0 | xargs -0 -I file mysql -hlocalhost -u#{db_username} -p#{db_password} #{db_database} < file"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-05
    • 2013-03-30
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多