Can not create migration (Laravel Framework 9.17.0) - php

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
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')
Any ideas what I might be doing wrong?

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';

You can try cleaning the cache by doing
php artisan config:cache
php artisan config:clear
php artisan cache:clear

Related

I am trying to migrate the table I have created but I keep getting an error that my database is unknown.I use XAMPP 3.3

SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
found this somewhere and it was helpful
The DB_USERNAME should be set to root if you do not have a default username
If no password is set on the database, clear it DB_PASSWORD
After completion of .env edit must be clear cache: php artisan config:cache
After Run the migrate Artisan command: php artisan migrate

What's wrong with query error in Laravel with XAMPP on Mac?

I am a beginner programmer and use Laravel with XAMPP on Mac. And all my attempts to create migrations lead to Query Error:
Illuminate\Database\QueryException
SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: select * from information_schema.tables where table_schema = laravel-app and table_name = migrations and table_type = 'BASE TABLE')
My PHP version is 7.3.29 on MacBook
In XAMPP web-server: Apache/2.4.48 (Unix) OpenSSL/1.1.1k PHP/8.0.10 mod_perl/2.0.11 Perl/v5.32.1
What steps should i take to customize the request?
This is not a Laravel issue, but a general MySQL Issue. Maybe the server is not running. Are you sure you're running MySQL in the background?
Check this link: MySQL Gone Away
Do the following checks in your system:
The Database Engine is running
You have created your database
You have created an user and granted permissions to the database
You have setup the user and the database in your Laravel's .env file.
After this, try to run the migrations command again, which is:
php artisan migrate
As explained Here

SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES) (SQL: select * from `cats`)

I am building a basic CRUD app using Laravel 7 Homestead in a Vagrant VM. The root address http://crud-app.local.test works, but when I add a defined route (http://crud-app.local.test/cats) I get this error page:
Error message in browser when navigating to '/cats' route.
So far I have:
Verified my MySQL password matches in the .env file and in practice
Changed the MYSQL password so that it's no longer empty (and made sure it matches what's in the .env file)
Ran php artisan config:cache
Ran php artisan config:clear followed by php artisan cache:clear
Changed 127.0.0.1 to localhost
Made sure the database defined in the .env file exists (crud)
Ran php artisan migrate (no errors, and the cats table exists in the crud database)
Restarted and re-provisioned the machine (vagrant reload --provision)
I'm at a loss now.
Make sure that you give "root" permissions to read from the database that you've created. As it's root#localhost rather than root#127.0.0.1 sometimes mysql differentiates. Just check the permissions that root#localhost has for the database and if you update them, flush the privileges.

Laravel 7 - migrate:refresh got access denied

I start to work on a laravel project that start by colleage. once I pulled down the git I want to do migration:
php artisan migrate:refresh
Immediately I got an error:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'172.19.0.1'
(using password: NO) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE
TABLE')
which seems odd because I checked all my config/database.php, .env, all point to 127.0.0.1 for mysql and not sure where 172.19.0.1 come from.
How can I debug this?
Please check your database, you have permissions issue for the database user.
Grant permissions for your db user root.
Execute the below command:
GRANT ALL PRIVILEGES ON dbname.* TO 'root'#'172.19.0.1';
FLUSH PRIVILEGES;

migrations file are not being created in laravel

I am trying to create a user table on my database, i type in composer:
C:\Users\Dell\proTest>php artisan make:migration users
Created Migration: 2017_04_30_195825_users
my .env file db, db username and pass are the same as my db created on my localhost, same with database.php file.
The problem is that it says that the migration has been created, but when i go on my laravel project files database/migrations I can not find the file ?
I have been trying to google the issue for several hours, I did clear the project cache, i did created a new project still not working! Any suggestion ?
when i run php aritsan migrate i get this error
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrat
ions)
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrat
ions)
If the database infos are the same on .env file as well as database.php. I am pretty sure your laravel path its not the same as the editor's path.
run:
C:\Users\Dell\proTes php artisan migrate
migration files can be here:
C:\Users\Dell\proTes\database\migrations

Categories