mozew's avatar
Level 6

Unsupported driver [file].

I am facing the issue of the unsupported driver while hitting my API I have the following configurations in my config/database.php

<?php

use Illuminate\Support\Str;

return [

	/*
	|--------------------------------------------------------------------------
	| Default Database Connection Name
	|--------------------------------------------------------------------------
	|
	| Here you may specify which of the database connections below you wish
	| to use as your default connection for all database work. Of course
	| you may use many connections at once using the Database library.
	|
	*/

	'default' => env('DB_CONNECTION', 'mysql'),

	/*
	|--------------------------------------------------------------------------
	| Database Connections
	|--------------------------------------------------------------------------
	|
	| Here are each of the database connections set up for your application.
	| Of course, examples of configuring each database platform that is
	| supported by Laravel is shown below to make development simple.
	|
	|
	| All database work in Laravel is done through the PHP PDO facilities
	| so make sure you have the driver for your particular database of
	| choice installed on your machine before you begin development.
	|
	*/

	'connections' => [

		'sqlite' => [
			'driver' => 'sqlite',
			'url' => env('DATABASE_URL'),
			'database' => env('DB_DATABASE', database_path('database.sqlite')),
			'prefix' => '',
			'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
		],
		'tracker' => [
			'driver'   => env('SESSION_DRIVER', 'database'),
			'host'     => env('DB_HOST', '127.0.0.1'),
			'database' => env('DB_DATABASE', 'forge'),
		'strict' => true,    // to avoid problems on some MySQL installs

	],

		'mysql' => [
			'driver' => 'mysql',
			'url' => env('DATABASE_URL'),
			'host' => env('DB_HOST', '127.0.0.1'),
			'port' => env('DB_PORT', '3306'),
			'database' => env('DB_DATABASE', 'forge'),
			'username' => env('DB_USERNAME', 'forge'),
			'password' => env('DB_PASSWORD', ''),
			'unix_socket' => env('DB_SOCKET', ''),
			'charset' => 'utf8mb4',
			'collation' => 'utf8mb4_unicode_ci',
			'prefix' => '',
			'prefix_indexes' => true,
			'strict' => true,
			'engine' => null,
			'options' => extension_loaded('pdo_mysql') ? array_filter([
				PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
			]) : [],
		],

		'pgsql' => [
			'driver' => 'pgsql',
			'url' => env('DATABASE_URL'),
			'host' => env('DB_HOST', '127.0.0.1'),
			'port' => env('DB_PORT', '5432'),
			'database' => env('DB_DATABASE', 'forge'),
			'username' => env('DB_USERNAME', 'forge'),
			'password' => env('DB_PASSWORD', ''),
			'charset' => 'utf8',
			'prefix' => '',
			'prefix_indexes' => true,
			'schema' => 'public',
			'sslmode' => 'prefer',
		],

		'sqlsrv' => [
			'driver' => 'sqlsrv',
			'url' => env('DATABASE_URL'),
			'host' => env('DB_HOST', 'localhost'),
			'port' => env('DB_PORT', '1433'),
			'database' => env('DB_DATABASE', 'forge'),
			'username' => env('DB_USERNAME', 'forge'),
			'password' => env('DB_PASSWORD', ''),
			'charset' => 'utf8',
			'prefix' => '',
			'prefix_indexes' => true,
		],

	],

	/*
	|--------------------------------------------------------------------------
	| Migration Repository Table
	|--------------------------------------------------------------------------
	|
	| This table keeps track of all the migrations that have already run for
	| your application. Using this information, we can determine which of
	| the migrations on disk haven't actually been run in the database.
	|
	*/

	'migrations' => 'migrations',

	/*
	|--------------------------------------------------------------------------
	| Redis Databases
	|--------------------------------------------------------------------------
	|
	| Redis is an open-source, fast, and advanced key-value store that also
	| provides a richer body of commands than a typical key-value system
	| such as APC or Memcached. Laravel makes it easy to dig right in.
	|
	*/

	'redis' => [

		'client' => env('REDIS_CLIENT', 'phpredis'),

		'options' => [
			'cluster' => env('REDIS_CLUSTER', 'redis'),
			'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
		],

		'default' => [
			'url' => env('REDIS_URL'),
			'host' => env('REDIS_HOST', '127.0.0.1'),
			'password' => env('REDIS_PASSWORD', null),
			'port' => env('REDIS_PORT', '6379'),
			'database' => env('REDIS_DB', '0'),
		],

		'cache' => [
			'url' => env('REDIS_URL'),
			'host' => env('REDIS_HOST', '127.0.0.1'),
			'password' => env('REDIS_PASSWORD', null),
			'port' => env('REDIS_PORT', '6379'),
			'database' => env('REDIS_CACHE_DB', '1'),
		],

	],

];

And my env file

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:EX/aHx0P3bXsYPNLAXa3NIeDfq7yDee4+eOfLTwphrE=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sarafi
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

I just wrote this command in a terminal, again my problem was not solved :

php artisan config:clear
0 likes
24 replies
Sinnbeck's avatar

Are there more lines to that error? Normally it says what caused the error

mozew's avatar
Level 6

@Sinnbeck I do not know what caused the error. Can you tell me where to find the error? Thanks

Sinnbeck's avatar

What is this, and why does it use the session driver?

'tracker' => [
			'driver'   => env('SESSION_DRIVER', 'database'),
			'host'     => env('DB_HOST', '127.0.0.1'),
			'database' => env('DB_DATABASE', 'forge'),
		'strict' => true,    // to avoid problems on some MySQL installs

//fixed assuming you want mysql
'tracker' => [
			'driver'   => 'mysql',
			'host'     => env('DB_HOST', '127.0.0.1'),
			'database' => env('DB_DATABASE', 'forge'),
		'strict' => true,    // to avoid problems on some MySQL installs  
mozew's avatar
Level 6

I create a database and put the name in .env. I see this error

error

Sinnbeck's avatar

@irankhosravi why are you trying to use multiple databases? Seems you are just making stuff harder for yourself?

mozew's avatar
Level 6

@Sinnbeck So what should I use? Is there a way to fix it other than the database?

Sinnbeck's avatar

@irankhosravi oh so you messed up your database? Not sure how to help you. You need to get it up and running again

Tray2's avatar

@irankhosravi Since it's Christmas I will give you some help.

  1. Open a command window
  2. Run mysql -uroot -p
  3. Enter the password you have set for the root user (enter if none)
  4. Update your .env to match the credentials for the root user.
mozew's avatar
Level 6

@Tray2

I see this

'mysql' is not recognized as an internal or external command, operable program or batch file.

Sinnbeck's avatar

@irankhosravi maybe just change your env back to how it looked a the start of this thread. I assume it worked then

mozew's avatar
Level 6

@Sinnbeck I am using xampp. Can you help me where to write it?

  • C:\xampp\mysql\data
  • C:\xampp\mysql\bin
  • My project
  • Or anywhere in Windows
Sinnbeck's avatar

@irankhosravi change your env file back to this..

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sarafi
DB_USERNAME=root
DB_PASSWORD= 
Tray2's avatar

@irankhosravi Then go to the folder where you have it installed and run the same command again.

Tray2's avatar

@irankhosravi You don't have enough computer knowledge to make it worth my time trying to explain something that is going to go way over your head anyway. I really think you should consider another profession that that of a developer.

1 like
dpelto's avatar

@irankhosravi you really don't know how to change to another folder?

You just:

cd c:\myfolder

Replacing c:\myfolder with a folder you need to change to.

Please or to participate in this conversation.