Laravel 7 php artisan migrate database error - laravel

When I run 'php artisan migrate' i am getting the following error
Access denied for user 'dbuser'#'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = dbname_main and table_name = migrations and table_type = 'BASE TABLE')
I have tried removing the vendor and reinstalling but no success. I am using php7.4
Is all the php extensions required for laravel 7.x is available for php7.4?

Usually you get this error with invalid db credentials.
Try using the correct ones.

Please double check the values that you set for your database variables (those prefixed with DB_) in your .env file

If you're sure your db credentials are correct, try:
php artisan config:clear
php artisan config:cache
php artisan cache:clear

Related

I type php artisan make:migartion ... and php artisan migrate, but table was not created

I create laravel5,mysql8 environment with docker-compose.
I create post table with laravel migration.
but I entered mysql container and checked if the table was created, but the table was not created.
I type php artisan make:migration create_posts_table and It works.
Then, I did the following.
as pictured, table is not exist.
why is this?
Thank you for your help.
have you run migrate in terminal? and check your table name
php artisan migrate
or check your env for db name

Bad: How can I migrate a table to a database in Laravel using terminal?

I am getting an error when I try to migrate a table from the migration directory to a database.
I want to migrate:
php artisan migrate:rollback --path=/database/migrations/2020_04_17_08144_create_car_production_dates_table.php
But I got this error.
Illuminate\Contracts\Filesystem\FileNotFoundException
File does not exist at path C:\Users\Yared Sisay\OneDrive\Desktop\Laravel\ProjectOne//database/migrations/2020_04_17_08144_create_car_production_dates_table.php.
What about path without /?
php artisan migrate --path=database/migrations/2020_04_17_08144_create_car_production_dates_table.php

Why am I getting this error with laravel websocket library?

am trying to set up a web sockets server using laravel 5.7 and keep getting this error
Argument 2 passed to
BeyondCode\LaravelWebSockets\Apps\App::__construct() must be of the
type string, null given, called in
/opt/lampp/htdocs/api.cs/vendor/beyondcode/laravel-websockets/src/Apps/ConfigAppProvider.php
on line 63 screenshot missing
....i don't know what to do please help. I'm actually using this guide https://docs.beyondco.de/laravel-websockets/1.0/
Try clearing your cache:
Run
php artisan config:cache
Or
php artisan optimize:clear
After running migration use the following sequence of commands:
php artisan cache:clear
php artisan config:clear
php artisan config:cache

why .env file configuration in laravel is not working

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=root
DB_PASSWORD=
this is my configuration for laravel 5.4
but php artisan migrate is not working and have error
and the migrate error
Users-MacBook-Pro: ATP Developers php artisan migrate
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user ''#'localhost' (using password: NO) (SQL: select * from information_schema.tables where table schema = atp_db and table_name = migrations)
In Connector.php line 87:
SQLSTATE[HY000] [1045] Access denied for user ''#'localhost' (using password: NO)
I faced a similar problem. So, I run the following commands as mentioned at
https://laracasts.com/discuss/channels/general-discussion/env-file-and-config-keys-not-updating-after-change,
php artisan cache:clear
php artisan config:clear
php artisan route:clear
Also, make sure to restart the server as well
php artisan serve
you should write these:
DB_DATABASE = your database name
DB_USERNAME = root
DB_PASSWORD = your password
and again run php artisan serve to make sure about saving .env and again run php artisan migrate
Indeed I had the same problem, I can not explain why Laravel indicates the old Host but the solution is to change the password.
Use below => php artisan config:cache
Change env host entry to DB_HOST=localhost. Or add the #'127.0.0.1' credentials to mysql.
The error indicates that you do not have the correct user and host combination in your database. The env file shows host is 127.0.0.1 but localhost is specified in the error. Add user#localhost entry to the database or user#% for wildcard.
This error would indicate that you don't have a database user configured in your .env file: ''#'localhost' . Your .env should have all those fields populated with the database name and credentials you configured before running any function that connects to the database.
Here are the preliminary steps to setup your database and .env file prior to running a php artisan migrate:
Hope it helps.
Step 1: Login to your mysql and create the database.
mysql -u root -p
create database just_brew_it;
Step 2: Although you can use root to authenticate via laravel, I'd create a new user to mitigate risk of any security issues:
GRANT ALL PRIVILEGES ON just_brew_it.* TO 'brew_user'#'%' identified by 'pint0fStell#' WITH GRANT OPTION;
FLUSH privileges;
Step 3: Modify your .env with the appropriate database, username and password
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= just_brew_it
DB_USERNAME= brew_user
DB_PASSWORD= pint0fStell#
This combo worked for me:
php artisan clear-compiled
composer dump-autoload
php artisan optimize
I had the same issue and i couldnt run "config:cache" artisan command even with Artisan::call('config:cache');
so i done this and solved my issue:
artisan config:cache caches all files from /config into a single array that it stores. It then reads all config variables from that array and ignores anything in .env or the /config files until you recache them. That's why it still works after deleting .env.
https://laravel.com/docs/5.6/configuration#configuration-caching
If you don't have ssh access to your live server, you'd just need to delete the bootstrap/cache/config.php file, which is the cache file config:cache generates.

Laravel 5 database.php set to sqlite - artisan uses mysql

I seem to be having a problem with artisan reading the default config/database.php file.
When I run for php artisan migrate:status - or any other migration related commands I get
exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access
denied for user 'homestead'#'localhost' (using password: YES)'
even though the default database connection name is set to sqlite, which doesn't require credentials of any kind.
My .env has APP_ENV=local and I'm running it under the local environment with PHP 5.6.2 using Mamp.
After calling php artisan I've noticed there is a command to clear the configuration cache file php artisan config:clear - then run php artisan config:cache to cache it with the applied changes - which solved the problem.

Resources