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

Vagrant Homestead错误:SSH命令以非零退出状态响应,vagrant,homestead,Vagrant,Homestead,当我在我的宅地机器上设置宅地时,我收到一个错误: ...[success logs here]... ==> default: Running provisioner: shell... default: Running: /var/folders/9j/bsvhbzdn2dx8hjwgnl7nrj7w0000gn/T/vagrant- shell20170127-4343-1dyyzgz.sh ==> default: mysql: ==> default: [Warnin

当我在我的宅地机器上设置宅地时,我收到一个错误:

...[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中创建的。所以我猜这个错误导致了这个问题


任何帮助都将不胜感激。

我相信这实际上是因为MySQL的密码有一个过期时间,而不是让它们永远有效。这似乎发生在我运行旧的Laravel Homestead 5盒子而不是Homestead 7+的新盒子时

请注意,以下解决方案还修复了
错误1820(HY000):在执行此语句之前,必须使用ALTER USER语句重置密码。

从主机:

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
mysql -h localhost -u homestead -p -e "DROP DATABASE homestead"
现在在客户端计算机中:

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
mysql -h localhost -u homestead -p -e "DROP DATABASE homestead"
现在从主机:

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
mysql -h localhost -u homestead -p -e "DROP DATABASE homestead"
它应该会起作用


但是,如果现在看到
==>默认值:createdb:数据库创建失败:错误:数据库“homestead”已存在
,请在客户端计算机中运行此行:

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
mysql -h localhost -u homestead -p -e "DROP DATABASE homestead"

然后从主机上运行
vagrant up--provision
,然后上路。

有没有办法将此包含在provision过程中,这样就不会手动完成?@Ali不幸的是,我现在对provision vagrant的了解不比你多。如果你或其他人发现了这一点,你能把步骤贴在这里吗?塔克斯!