Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a local database that I can connect to no problem using straight php

Working Example

However, when I use the same settings in Laravel, I get an access denied error message

enter image description here

I checked stackoverflow for this type of error and most cases is solved by using 127.0.0.1. I made sure to try both 127.0.0.1 and localhost whenever asked for host/server.

Also, I made sure root had sufficient privileges

mysql User Root Privileges

Here are my configuration settings, I tried to use different accounts, other than root, and also changing 127.0.0.1 to localhost (and the opposite)

database.php file

enter image description here

.env file

enter image description here

Hoping to learn this framework, I've heard great things. Appreciate any help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
153 views
Welcome To Ask or Share your Answers For Others

1 Answer

Sounds like you are trying the connection both with the script and laravel from a different Server like homestead.

Normally there are restrictions that you can't connect from remote (i.e. from a VM like homestead) to a certain server (i.e. localhost) with the root user.

Possible Solutions: 1. Create another user with the relevant permissions on mysql and connect with that one. 2. Look in the web for how to allow remote connections 3. Go the laravel way and use the homestead DB inside of the VM


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...