Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yuukuari's avatar

Homestead fails to create mysql database

I installed homestead for laravel on my mac by following the official tutorial.

After a few hours everything works fine except for the database creation. I tried to remove then reinstall homestead but i have the same issue.

yuukuari$ homestead reload --provision
 ==> default: Attempting graceful shutdown of VM...
 ==> default: Checking if box 'laravel/homestead' is up to date...
 ==> default: Clearing any previously set forwarded ports...
 ==> default: Clearing any previously set network interfaces...
 ==> default: Preparing network interfaces based on configuration...
     default: Adapter 1: nat
     default: Adapter 2: hostonly
 ==> default: Forwarding ports...
     default: 80 (guest) => 8000 (host) (adapter 1)
     default: 443 (guest) => 44300 (host) (adapter 1)
     default: 3306 (guest) => 33060 (host) (adapter 1)
     default: 5432 (guest) => 54320 (host) (adapter 1)
     default: 22 (guest) => 2222 (host) (adapter 1)
 ==> default: Running 'pre-boot' VM customizations...
 ==> default: Booting VM...
 ==> default: Waiting for machine to boot. This may take a few minutes...
     default: SSH address: 127.0.0.1:2222
     default: SSH username: vagrant
     default: SSH auth method: private key
     default: Warning: Remote connection disconnect. Retrying...
 ==> default: Machine booted and ready!
 ==> default: Checking for guest additions in VM...
     default: The guest additions on this VM do not match the installed version of
     default: VirtualBox! In most cases this is fine, but in rare cases it can
     default: prevent things such as shared folders from working properly. If you see
     default: shared folder errors, please make sure the guest additions within the
     default: virtual machine match the version of VirtualBox you have installed on
     default: your host and reload your VM.
     default: 
     default: Guest Additions Version: 5.0.20
     default: VirtualBox Version: 5.1
 ==> default: Setting hostname...
 ==> default: Configuring and enabling network interfaces...
 ==> default: Mounting shared folders...
     default: /vagrant => /Users/yuukuari/Homestead
     default: /home/vagrant/Code => /Users/yuukuari/Code
 ==> default: Running provisioner: file...
 ==> default: Running provisioner: shell...
     default: Running: inline script
 ==> default: Running provisioner: shell...
     default: Running: inline script
 ==> default: Running provisioner: shell...
     default: Running: /var/folders/zn/1n81dnzj3bq_5lrrxrqw6zmr0000gn/T/vagrant-shell20160911-6890-jawt7s.sh
 ==> default: Running provisioner: shell...
     default: Running: script: Creating Site: decorey.app
 ==> default: Running provisioner: shell...
     default: Running: script: Creating Schedule
 ==> default: Running provisioner: shell...
     default: Running: script: Restarting Nginx
 ==> default: Running provisioner: shell...
     default: Running: script: Creating MySQL Database
 ==> default: ERROR
 ==> default:  2002 (HY000)
 ==> default: : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
 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.

In my homestead vagrant, there is no mysql socket and i can't start mysql. I also tried to add mariadb: true to the Homestead.yaml file but it changes nothing.

vagrant@homestead:/etc$ sudo find / -type s
  /run/supervisor.sock
  /run/rpcbind.sock
  /run/uuidd/request
  /run/dbus/system_bus_socket
  /run/user/900/systemd/private
  /run/user/900/systemd/notify
  /run/postgresql/.s.PGSQL.5432
  /run/php/php7.0-fpm.sock
  /run/lvm/lvmetad.socket
  /run/lvm/lvmpolld.socket
  /run/systemd/fsck.progress
  /run/systemd/journal/dev-log
  /run/systemd/journal/socket
  /run/systemd/journal/stdout
  /run/systemd/journal/syslog
  /run/systemd/private
  /run/systemd/notify
  /run/udev/control
  /tmp/ssh-YqUsV7ubPF/agent.2197
vagrant@homestead:/etc$ sudo service mysql status
    ● mysql.service - MySQL Community Server
       Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
       Active: inactive (dead) (Result: exit-code) since Sun 2016-09-11 07:52:55 UTC; 1h 17min ago
  Process: 932 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Sep 11 07:52:54 homestead systemd[1]: mysql.service: Unit entered failed state.
Sep 11 07:52:54 homestead systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 11 07:52:55 homestead systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 11 07:52:55 homestead systemd[1]: Stopped MySQL Community Server.
Sep 11 07:52:55 homestead systemd[1]: mysql.service: Start request repeated too quickly.
Sep 11 07:52:55 homestead systemd[1]: Failed to start MySQL Community Server.
vagrant@homestead:/etc$ sudo service mysql start
        Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
vagrant@homestead:/etc$ sudo service mysqld start
Failed to start mysqld.service: Unit mysqld.service not found.

I have spent hours looking for a solution but i can't find anybody having the same issue :(

Thanks for your help

0 likes
4 replies
Kemito's avatar

Don`t bother to just install needed version (i believe latest) of MySQL on your VM

Then reload it again. Also you can install and check if the socket is in the right place and you can log into your mysql on VM.

yuukuari's avatar
yuukuari
OP
Best Answer
Level 1

Destroying and installing again the homestead worked. I thought i had destroyed the box already but i had just removed it, so when i added it again it kept the config unchanged. Thanks for your help

Please or to participate in this conversation.