Homestead错误:SSH命令以非零退出状态响应

时间:2017-01-27 14:39:25

标签: vagrant homestead

我在家用机器上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中创建的。所以我猜这个错误导致了这个问题。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:3)

我认为这实际上是由于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并继续前进。