2021年1月7日星期四

"Access denied for user, using password: yes" Laravel 8 Heroku

Here is the config/database.php file that I modified using this tutorial. It says that I need to attach the $DATABASE_URL=parse_url("mysql://####"); code block above the said php page. (the tutorial is using postgreSQL, while my system needs to use MySQL).

// attached $DATABASE_URL=parse_url("mysql://####") on the topmost part of the page      'mysql' => [              'driver' => 'mysql',              'url' => env('DATABASE_URL'),              'host' => $DATABASE_URL['host'], // edited this line              'port' => $DATABASE_URL['port'], // edited this line              'database' => ltrim($DATABASE_URL['path'], '/'), // edited this line              'username' => $DATABASE_URL['user'], // edited this line              'password' => $DATABASE_URL['pass'], // edited this line              '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'),              ]) : [],          ],  

below is the original mysql code

        // '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'),          //     ]) : [],          // ],  

error ouput when running the system with the said problem

SQLSTATE[HY000] [1045] Access denied for user ''@'' (using password: YES) (SQL: select * from video_links where home_video = true and video_links.deleted_at is null limit 1)

Another problem I encounter while running the migration command in the Heroku CLI is this:

PHP Warning:  Undefined array key "port" in /app/config/database.php on line 51  

It seems like the $DATABASE_URL=parse_url("mysql://####") is not fetching the port value in its array.

How should I approach this?

https://stackoverflow.com/questions/65622874/access-denied-for-user-using-password-yes-laravel-8-heroku January 08, 2021 at 11:02AM

没有评论:

发表评论