• Databases
  • Laravel error connection database (SQLSTATE[HY000] [2002] Permission denied)

I am having problem with my Laravel application, i use the MySQL database and trying connect my application in .env file, but i do not understand how to set the information rights to work.

My .env file is:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=my_database
DB_USERNAME=my_user
DB_PASSWORD=my_password

The error is SQLSTATE[HY000] [2002] Permission denied.

The problem may is between DB_CONNECTION, DB_HOST and DB_PORT. I don't set my Laravel application in serv00.com

admin i already created my database in MySQL when i make a deploy of my Laravel application, and also imported the database of my local machine to server database.

@admin thank you, i solved my question.

DB_CONNECTION=mysql
DB_HOST=mysql2.serv00.com
DB_PORT=3306
DB_DATABASE=my_database
DB_USERNAME=my_username
DB_PASSWORD=my_password