1

I have a laravel project on my Godaddy shared server and have been working on it for the past several weeks including running many 'php artisan migrate' commands. Inside my .env file I have been using the username and password of the entire cPanel. For security I decided to create a new DB users who only has privileges to the database I'm working on and use that inside the .env file. However, no matter what I do, I get the following error:

 Illuminate\Database\QueryException  : SQLSTATE[28000] [1045] Access denied for user 'seconduser'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = Custom_Database and table_name = migrations)

I've followed every solution to this error I can find which advise me to double, and triple check my credentials (which I can confirm are 100% correct) being used in the .env file.

I've also tried creating a third DB user account which also has full privileges to the DB, but once again, I get the same error.

I've also tried changing my .env $host variables to the actual IP of my server, but the error is the same.

Finally, it's worth mentioning that, the way I'm creating my database users is via the GoDaddy MySQL Databases panel like they recommend and not directly inside PHPMyAdmin.

My .env file is below, any help would be much appreciated:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Custom_Database
DB_USERNAME=seconduser
DB_PASSWORD=C0mp13XPA$$W0rD

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

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

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

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
JamMan9
  • 706
  • 2
  • 9
  • 22
  • Godaddy provide thirdclass services dont use it , use Hostinger https://www.hostinger.com/ they also provide access to SSH terminal where you can run artisan commands – Saurabh Mistry Jun 06 '18 at 10:25
  • I'm already on Godaddy and have a plan with them. It would be good to have a solution. Surely this problem can't purely be a Godaddy thing? – JamMan9 Jun 06 '18 at 10:27
  • Can you try putting `var_dump(mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db")); exit;` (with your credentials) at the start of your `public/index.php` file. Just for the sake of testing? – Ivanka Todorova Jun 06 '18 at 10:42
  • DId you find any solution? –  Oct 22 '19 at 20:29

1 Answers1

0

Just use username and password with double quotes like

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Custom_Database
DB_USERNAME="seconduser"
DB_PASSWORD="C0mp13XPA$$W0rD"

It resolve the issue.