简体   繁体   中英

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?

在此处输入图像描述

(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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM