skip to Main Content

I am trying to use my project on godaddy but it is constantly giving me an error:

SQLSTATE[28000] [1045] Access denied for user ‘nagesh’@’ip-address of
the website
‘ (using password: YES) (SQL: select * from admins where
email = admin limit 1).

Although my credentials should be correct as they are created in the godaddy cpanel but still I am having this error. I searched a lot on stackoverflow and tried many solutions but nothing seems to be working. This is my .env file:

APP_ENV=local
APP_KEY=base64:Qx5MJdayISVHcd5p9nW0zJvb4BC6jyWD9BySf4j8yis=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST="IP address of the website"
DB_PORT=3306
DB_DATABASE=ncminsti_ncm
DB_USERNAME="username i created using the cpanel's add new user form"
DB_PASSWORD="password created with above user."

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

I believe am doing some mistake in my .env file. Probably the DB_Host field is wrong. I am new to laravel and not sure what should be the correct configuration for .env file. Please help me in connecting to the DB. Thank you.

2

Answers


  1. If website and database are on the same server, then:

    DB_HOST=127.0.0.1

    Login or Signup to reply.
  2. You will need to try and connect to your database first:

    mysql -h <thehost> -u <theuser> -p
    

    This will either ask you to type your password or report an error. Since Laravel could not connect to your database (ultimately generating something like the above), it is safe to assume that the command above will fail. You will need to find out what the problem is, solve that and then apply the solution to your Laravel environment as well.

    It is very possible that you had a typo in the username/password or defined your hostname incorrectly. It is possible that you just need to connect to localhost (127.0.0.1), but it’s also possible that the server is located either on a remote computer or an image (like a Docker image). You may also need to connect to a VPN or whitelist your IP address. Try contacting your sysadmin to find out how you can connect to your database on the Command-Line Interface and once that works, apply the same idea in your Laravel config.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search