Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RohitM-IN opened this issue Oct 30, 2020 · 2 comments

Comments

@RohitM-IN
Copy link

RohitM-IN commented Oct 30, 2020

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
@Final9800
Copy link

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

@jacodhis
Copy link

jacodhis commented Jul 4, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants