Homestead error: The SSH command responded with a non-zero exit status

匿名 (未验证) 提交于 2019-12-03 00:52:01

问题:

I get an error when I do homestead up --provision on my homestead machine:

...[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. 

Although I get this error, everything works fine except one:

Databases that I have defined in ~/.homestead/Homestead.yaml are not created in mysql. So I guess this error causes the issue.

Any help would be appreciated.

回答1:

I believe this is actually due to MySQL having an expiration time on passwords rather than having them last forever. It seems to happen for me when I'm running my old Laravel Homestead 5 box instead of newer ones for Homestead 7+.

Note that the following solution also fixes ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

From the host machine:

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

Now within the client machine:

# 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 

Now from the host machine:

vagrant up --provision 

And it should work.


However, if you now see ==> default: createdb: database creation failed: ERROR: database "homestead" already exists then run this line within the client machine:

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

Then run vagrant up --provision from the host machine and be on your way.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!