tracker icon indicating copy to clipboard operation
tracker copied to clipboard

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

Open RohitM-IN opened this issue 3 years ago • 2 comments

Describe the bug

//database.php inside connections

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],
....
        'tracker' => [
            'driver'   => 'mysql',
            'host'     => 'localhost',
            'database' => 'trackers', //created different db since its mentioned 
            'strict' => false,    // to avoid problems on some MySQL installs
        ],

and my env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravelwebsite
DB_USERNAME=root
DB_PASSWORD=

To Reproduce Steps to reproduce the behavior:

  1. Enter command php artisan tracker:tables ---------> //success
  2. then php artisan migrate
  3. See error

Screenshots

image

System

  • OS: Windows 10
  • Browser chrome

RohitM-IN avatar Oct 30 '20 10:10 RohitM-IN

Hi, I know this is an old Issue and I don't know rather your problem had been solved or not.

These errors because of the setup tracker. In the documentation installation, it seems that there is lack of parameters needed for the database connection.

In the database connection on your config/database.php try to add the username and password in the tracker database connection cause it seems there is a need in the connection. Also it is preferable to use env as the tracker connection will update accord to the change of your enviroment

'connections' => [
      'mysql' => [
          'driver' => 'mysql',
          'url' => env('DATABASE_URL'),
          'host' => env('DB_HOST', '127.0.0.1'),
          'port' => env('DB_PORT', '3306'),
          'database' => env('DB_DATABASE', 'forge'),
          'username' => env('DB_USERNAME', 'forge'),
          'password' => env('DB_PASSWORD', ''),
          'unix_socket' => env('DB_SOCKET', ''),
          'charset' => 'utf8mb4',
          'collation' => 'utf8mb4_unicode_ci',
          'prefix' => '',
          'prefix_indexes' => true,
          'strict' => true,
          'engine' => null,
          'options' => extension_loaded('pdo_mysql') ? array_filter([
              PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
          ]) : [],
      ],
      ....
      'tracker' => [
          'driver'   => 'mysql',
          'host'     => env('DB_HOST', '127.0.0.1'),
          'database' => env('DB_DATABASE', 'forge'), //created different db since its mentioned
          'username' => env('DB_USERNAME', 'forge'),
          'password' => env('DB_PASSWORD', ''),
          'strict' => false,    // to avoid problems on some MySQL installs
      ],
],

After adding the tracker connection on config/database.php do remember to php artisan config:cache

After that you could safely migrate the tracker table php artisan migrate

Final9800 avatar May 15 '21 15:05 Final9800

thanks much. I had the same problem ..added the tracker connection and it worked

jacodhis avatar Jul 04 '22 12:07 jacodhis