I have checked this issue on this forum but couldn't solve it.
.env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=channelable
DB_USERNAME=root
DB_PASSWORD=root
and database.php
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'channelable'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'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'),
]) : [],
],
I am sure that the database username and password are: root
I use php artisan config:clear
and php artisan cache:clear
commands but still show me a error.
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = channelable and table_name = migrations and table_type = 'BASE TABLE')
Can you help me?
CodePudding user response:
Try this in terminal:
sudo mysql -u root mysql> ALTER USER the_user IDENTIFIED WITH mysql_native_password BY 'the_password';
CodePudding user response:
I faced the same issue few weeks ago and even after changing the user details from terminal, the error persistsed.
Below was how I resolved it. Enclose the DB_USERNAME and DB_PASSWORD values in double quotes as shown below:
DB_USERNAME="root"
DB_PASSWORD="root"
Maybe that will help.