Search code examples
phplaravelubuntu-20.04laravel-9laravel-migrations

Can not create migration (Laravel Framework 9.17.0)


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?


Solution

  • 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