Reputation: 228
I have problems in connected with laravel to mysql database. I have change the localhost to localhost:8091 because this is the local server name in my wamp server. I have also installed xampp and uniserver which listens to other ports. Is it possible that laravel i confused with the other servers i have installed in my machine? Not only for the url but for the phpmyadmin too, for example.
this is the error
PDOException in Connector.php line 119: could not find driver
This is my .env file
APP_ENV=local
APP_KEY=base64:h0GyUa1VdjV22LXpRiOSOw+9HxXV+Qm0XO2zz9RRz6s=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost:**8091**
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=test1
DB_USERNAME=root
DB_PASSWORD=
This is my config.php file
'mysql' =>
array (
'driver' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'database' => 'test1',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => NULL,
),
This is my database.php file
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'test1'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
Solution on last comment of correct answer
Upvotes: 0
Views: 9855
Reputation: 1903
You can quickly check if there's a problem with php config. Find your php.ini file, it should be somewhere in xampp folders - do a file search if you have trouble finding it.
Alternatively, you can create a simple file like this:
<?php
phpinfo();
Or do it the laravel way:
Route::get('info', function() { phpinfo(); });
Now call that route through the browser - you will see php configs.
What you're looking is pdo_mysql. See if it is enabled. If it isn't, go to your php.ini file and find the following line:
extension=php_pdo_mysql.dll
Make sure it is uncommented. Restart you servers and you should be good to go.
Also, you do not need to make any changes to database.php or app.php files to connect to the database - changing .env is enough, so remove database connection details from your source files, just leave them as they were initially. Since most of your settings are the same as the defaults, the only parameters that you have to set in .env are:
DB_DATABASE=test1
DB_USERNAME=root
Try these things and let me know if it helps :)
Upvotes: 1