Arnon
Arnon

Reputation: 31

Why I can't access database through mysql workbench using laravel homestead?

I'm tying to connect to my database created called 'bacon' using the mysql workbench but I' can't have access. I start the VM using vagrant up with the configured files. I tried the two ports 3306 and 33060 and the two IPs 127.0.0.1 and 192.168.10.10 but I got access denied as shown in image below. Can someone help me?

enter image description here

(I'm using Laravel Homestead 8.17.2 running on win10 through VS code)

.env file configuration:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=bacon
DB_USERNAME=root
DB_PASSWORD=secret

If I run from my VM:

mysql> show databases;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
| bacon               |
| homestead           |
| #mysql50#lost+found |
| mysql               |
| performance_schema  |
| sys                 |
+---------------------+
7 rows in set (0.00 sec)

Homestead.yaml file:

[...]
sites:
    - map: bacon.test
      to: /home/vagrant/code/bacon/public

databases:
    - homestead
    - bacon

features:
    - mysql: true
    - mariadb: false
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

Upvotes: 1

Views: 952

Answers (2)

Spencer Hill
Spencer Hill

Reputation: 1005

For others that this doesn't work for try the alternate IP of 192.168.10.10

hostname  = 192.168.10.10
port = 3306
username = homestead
password = secret

This works for me on Windows 10 Home Version 20H2 OS Build 19042.1165 (To find this information navigate to Start, Type 'About' and click 'About your PC').

Upvotes: 0

Alex Mac
Alex Mac

Reputation: 923

In homestead the default database user is homestead and the password secret. So root won't work. Look here at the documentation about connecting to your homestead MySql instance. https://laravel.com/docs/8.x/homestead#connecting-to-databases

Upvotes: 2

Related Questions