user3718908x100
user3718908x100

Reputation: 8509

Configuring Homestead to work with MySQL Workbench

I just started using Homestead today and so far I don't think I know what I am doing, previously I was using the inbuilt PHP server that comes with Laravel and I had MySQL server and workbench installed separately on my computer.

With this setup I was able to connect to my database with ease, however since I got my Homestead running I can't seem to access that database again. This error keeps popping up:

3/3 ErrorException in Connector.php line 47: SQLSTATE[HY000] [1045] 
Access denied for user 'myproject_db101'@'localhost' (using password: YES) 
(View: /home/vagrant/Projects/myproject/resources/views/layout/index.blade.php) 
(View: /home/vagrant/Projects/myproject/resources/views/layout/index.blade.php) 

How can I fix this?

Upvotes: 6

Views: 10519

Answers (4)

These other answers might have worked for you guys, but in case anyone has a case like mine, I'm just going to provide what worked for me. Hopefully it helps someone out. I'm working on a brand new homestead installation as of today, but on a very old mac in case thats relevant.

What worked for me was using the regular localhost ip of my machine as the host, and then the homested/secret combination for the password, and using the default port but with a 0 at the end. This adds up to be the following settings:

Connection method: Standard (TCP/IP)

Host: 127.0.0.1
Username: homestead
Password: secret
Port: 33060

Hopefully this helps someone out. Its the only configuration that worked for me.

Upvotes: 2

Prakhar
Prakhar

Reputation: 1075

I was facing the same issue and I tried below steps to fix it. Please let me know if they work for you.

  1. Note the homestead ip address for your vagrant box. It is available in Homestead.yaml file under ~/.homestead directory. This directory location would be different on different OS. But since you have already installed vagrant with homestead you should know its location. For me the ip address was 192.168.10.10.
  2. Open up the Mysql Connection wizard and provide the below settings hostname = 192.168.10.10 port = 3306 username = homestead password = secret
  3. Test Your connection

For me these settings worked. Check if they work for you.

Upvotes: 26

Drew Hammond
Drew Hammond

Reputation: 588

Try using homestead's default MySQL credentials: User: root Password: secret

If you are accessing the database from your computer via MySQL Workbench (not from within the homestead VM), you can use localhost:33060 (note: non-standard port). This is mapped to port 3306 within your VM.

From your application and any time you're working from within the homestead VM, you can connect to the database normally as localhost on port 3306.

Upvotes: 1

Mike Lischke
Mike Lischke

Reputation: 53357

Very likely a configuration issue. Either the user 'myproject_db101'@'localhost' has no password set or is not allowed to connect from localhost. You need another user with proper rights (e.g. the root user) to fix permissions for that user.

Upvotes: 0

Related Questions