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