'MYSQL not connecting to LARAVEL but credentials are correct and cant use artisan command

On the webpage this is produced: sqlstate[hy000] [1698] access denied for user 'root'@'localhost' (sql: select * from information_schema.tables where table_schema = laravel and table_name = categories and table_type = 'base table')

Attempts:

  1. php artisan config:cache, php artisan config:clear, php artisan cache:clear => Not working since artisan displays the mysql error; so artisan is useless, it must be a database issue
  2. env file credentials are correct
  3. sudo systemctl restart mysql.service => problem persists
  4. restart the DO Server with sudo poweroff => problem persists


Solution 1:[1]

The Solution:

  1. sudo mysql -u root -p => login to mysql as root with password

  2. use mysql; => use the mysql database

  3. UPDATE user SET plugin='mysql_native_password' WHERE USER='root'; => change the authentication type of root to mysql_native_password

  4. FLUSH PRIVILEGES; => reload the grant table

  5. service mysql restart => restart mysql

After this is completed, the error should be cleared.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 darylvickerman