Laravel provides an interactive shell called Tinker, which allows you to test database connections easily. Run:
php artisan tinker
Then, in the interactive shell, try the following:
DB::connection('NameDB')->getPdo();
echo "Connected successfully to Name DB";

If your connection is successful, it will return a message without errors.
If there is an issue, you will see a PDOException error, which could indicate:
- Incorrect credentials in
.env
- Database is not running
- Incorrect database name or host