0

When I try to connect to my database i get this error

[PDOException]                                                               
SQLSTATE[HY000] [1045] Access denied for user 'loom'@'localhost' (using password: YES)

all my credentials are correct and when i change things up i get this error :

[PDOException]                                        
SQLSTATE[HY000] [1049] Unknown database 'loomcoding'

Can anyone help me sort this out please

my .env file

APP_ENV=local
APP_DEBUG=true
APP_KEY=xxxx

DB_HOST=localhost
DB_DATABASE=cl20-loom
DB_USERNAME=loom
DB_PASSWORD=xxxx

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

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

my database.php file :

'mysql' => [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'cl-loom',
        'username'  => 'loom',
        'password'  => '••••',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],
RyanM
  • 751
  • 5
  • 20

3 Answers3

1

It can be because the mysql service is not running or it isn't on the port 3306, in the last case you may specify the port where the mysql service is running as a attribute port of the mysql object in database.php file

1

If you are using mysql you have to create the database manually in phpMyAdmin or whatever software you are using for mysql.

And no need to change the whole database.php if you configure the .env file. Just change this line 'default' => env('DB_CONNECTION', 'mysql'), in database.php

Below code is not tested

Instead, you can add DB_CONNECTION=mysql this line in .env

smartrahat
  • 5,381
  • 6
  • 47
  • 68
1

I got this error last time create a database on phpmyadmin and change only the .env file to match with you phpmyadmin details and it will work.