skip to Main Content

I want to connect the MySQL database to the Laravel project without XAMPP (Using Ubuntu 22.04).
I created a database called my_project and added it to.env file
enter image description here

Up next to create migrations I used artisan command: php artisan migrate.
As an output it returned

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = my_database and table_name = migrations and table_type = 'BASE TABLE')

enter image description here

Any ideas what I might be doing wrong?

2

Answers


  1. Chosen as BEST ANSWER

    Apparently, my dad found the answer to my problem :D problem was in giving my database user grant only for localhost. However, it needs to be granted so it can be connected from any IP.

    CREATE USER 'amir'@'%' IDENTIFIED BY 'password';
    

    enter image description here


  2. You can try cleaning the cache by doing

    php artisan config:cache
    php artisan config:clear
    php artisan cache:clear
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search