【问题标题】:Homestead error: The SSH command responded with a non-zero exit statusHomestead 错误:SSH 命令以非零退出状态响应
【发布时间】:2017-01-27 14:39:25
【问题描述】:

在我的宅基地机器上执行homestead up --provision 时出现错误:

...[success logs here]...
==> default: Running provisioner: shell...
default: Running: /var/folders/9j/bsvhbzdn2dx8hjwgnl7nrj7w0000gn/T/vagrant-
shell20170127-4343-1dyyzgz.sh
==> default: mysql: 
==> default: [Warning] Using a password on the command line interface
 can be insecure.
==> default: Please use --connect-expired-password option or invoke
 mysql in interactive mode.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

虽然我收到此错误,但一切正常,除了一个:

我在~/.homestead/Homestead.yaml 中定义的数据库不是在mysql 中创建的。所以我猜这个错误会导致问题。

任何帮助将不胜感激。

【问题讨论】:

    标签: vagrant homestead


    【解决方案1】:

    我相信这实际上是由于 MySQL 对密码有一个过期时间,而不是让它们永远持续下去。当我运行旧的 Laravel Homestead 5 而不是新的 Homestead 7+ 时,这似乎发生在我身上。

    请注意,以下解决方案还修复了ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    从主机:

    vagrant up
    # ignore "SSH command responded with a non-zero exit status"
    vagrant ssh
    

    现在在客户端机器中:

    # log into mysql (for Homestead your password is likely "secret")
    mysql -h localhost -u homestead -p
    
    SET PASSWORD = PASSWORD('secret');
    
    -- A) set password to never expire:
    ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
    
    -- or B) to change password as well:
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password', 'root'@'localhost' PASSWORD EXPIRE NEVER;
    
    -- quit mysql
    quit
    
    # exit back to host shell
    exit
    

    现在来自主机:

    vagrant up --provision
    

    它应该可以工作。


    但是,如果您现在看到 ==> default: createdb: database creation failed: ERROR: database "homestead" already exists,则在客户端计算机中运行此行:

    mysql -h localhost -u homestead -p -e "DROP DATABASE homestead"
    

    然后从主机运行vagrant up --provision 并继续前进。

    【讨论】:

    • 有没有办法将此包含在配置过程中,这样就不会手动完成?
    • @Ali 不幸的是,我目前对配置 Vagrant 的了解并不多。如果您或其他人弄清楚了,您能否在此处发布步骤?谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-22
    • 1970-01-01
    • 2019-11-28
    • 2016-07-11
    • 2021-02-15
    • 1970-01-01
    相关资源
    最近更新 更多