I am working on Laravel project hosted on AWS EC2(Ubuntu) with RDS(MySQL) on the same VPC. I can connect to MySQL through command line with no problem, but when Laravel app tries to connect to database, the access is denied.
SQLSTATE[HY000] [1045] Access denied for user 'username'@'ipaddress' (using password: Y ES) (SQL: select * from
tablename
)
Below is my DB config in.env file:
DB_HOST=verylonghostname.rds.amazonaws.com
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=dbusername
DB_PASSWORD=dbpassword
What might be the problem and how can I fix it?
I tried create another db user for laravel and it works. Apparently the connection is denied if I use db user name 'admin'. Perhaps it is one of security measure by AWS.
I was having the same issue, ie I was able to connect to the database through dBeaver as well as through a php file contained in the /var/www/html folder. However, it would not connect through Laravel app. The issue got fixed after I enclosed the password within quotes in the ".env" file.
DB_PASSWORD='xyz#xxxccc'
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.