hanie
hanie

Reputation: 328

"SQLSTATE[42000] [1044] Access denied for user 'team'@'localhost' to database 'my database''

I want upload my Laravel Project in Cpanel.

The first page is the login page for users that when a user logins, he is redirected to another page.

When I want to send the user information to the database, I get this error:

"SQLSTATE[42000] [1044] Access denied for user 'team'@'localhost' to database 'my database'"

In Cpanel I'm creating a database and a user.

In phpMyAdmin I'm creating my tables.

Alson in env file I Add username and database name,

Where is my mistake? How can I solve it?

Upvotes: 3

Views: 8410

Answers (3)

Hammad Bukhari
Hammad Bukhari

Reputation: 19

This error occurs mostly in the live server go to the panel then go to MySQL Databases and add user privilege to the database you want then put these user credentials in yours.env file

Upvotes: 1

I. Antonov
I. Antonov

Reputation: 688

Fist check your .env file. Make sure you put the right credentials for the database name, username and password. The database name and username in cPanel ususally starts with your cPanel username, such as cPanelUsername_databaseName.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cpanelUsername_databaseName
DB_USERNAME=cpanelUsername_databaseUser
DB_PASSWORD=thePasswordYouSet

If that does not solve the problem, you might want to check if you have the user added to the database. You will find it in the MySQL Database. If not, then navigate to the MySQL Database section inside the cPanel and scroll down and you will find Add User To Database and then select the user that you want to give permission to access the database.

Upvotes: 1

Mahfuz Shishir
Mahfuz Shishir

Reputation: 841

Change your .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database_name
DB_USERNAME=user_name
DB_PASSWORD=user_password

Upvotes: 2

Related Questions