-2

I'm making an app with Laravel, and when I try to run a migration, I get this error.

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

How can I fix this?

Nailuj29
  • 750
  • 1
  • 10
  • 28
  • Does this answer your question? [SQLSTATE\[HY000\] \[1698\] Access denied for user 'root'@'localhost'](https://stackoverflow.com/questions/36864206/sqlstatehy000-1698-access-denied-for-user-rootlocalhost) – esqew Mar 31 '21 at 19:15
  • Use some GUI client like phpMyAdmin and check if you have root account and it accepts connections from localhost. – biesior Mar 31 '21 at 19:15
  • @esqew no, that didn't work – Nailuj29 Mar 31 '21 at 21:24
  • @biesior how can I install phpMyAdmin on Pop OS – Nailuj29 Mar 31 '21 at 21:25
  • Go to phpmyadmin.net and read user's manual. On the other hand while you're on Linux you can easily go to terminal and run mysql client there – biesior Mar 31 '21 at 21:28

2 Answers2

0
  1. Check user details in .env file. You should have user credentials in .env and user with them in sql(use phpmyadmin to simplify process)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Database
DB_USERNAME=root
DB_PASSWORD=
  1. Run in your app folder the php artisan config:cache command, if you sure that user credentials are correct in .env
BetelGoose
  • 5
  • 1
  • 4
0

To fix this, I ended up creating a new user just for the laravel app.

Nailuj29
  • 750
  • 1
  • 10
  • 28