2
respostas

PDOException in Connector.php line 47:

Ao fazer a conexão no arquivo database.php

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'estoque_laravel'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

Ao entrar na URL: http://localhost:8000/produtos me informa o seguinte erro

PDOException in Connector.php line 47:
could not find driver

in Connector.php line 47
at PDO->__construct('mysql:host=localhost;dbname=estoque_laravel', 'root', '', array('0', '2', '0', false, false)) in Connector.php line 47
at Connector->createConnection('mysql:host=localhost;dbname=estoque_laravel', array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'estoque_laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 20
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'estoque_laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 58
at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'estoque_laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 47
at ConnectionFactory->make(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'estoque_laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), 'mysql') in DatabaseManager.php line 177
at DatabaseManager->makeConnection('mysql') in DatabaseManager.php line 65
at DatabaseManager->connection() in DatabaseManager.php line 304
at DatabaseManager->__call('select', array('SELECT * FROM produtos')) in Facade.php line 210
at Facade::__callStatic('select', array('SELECT * FROM produtos')) in ProdutoController.php line 8
at ProdutoController->lista()
at call_user_func_array(array(object(ProdutoController), 'lista'), array()) in Controller.php line 246
at Controller->callAction('lista', array()) in ControllerDispatcher.php line 162
at ControllerDispatcher->call(object(ProdutoController), object(Route), 'lista') in ControllerDispatcher.php line 107
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 100
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 108
at ControllerDispatcher->callWithinStack(object(ProdutoController), object(Route), object(Request), 'lista') in ControllerDispatcher.php line 65
at ControllerDispatcher->dispatch(object(Route), object(Request), 'estoque\Http\Controllers\ProdutoController', 'lista') in Route.php line 204
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 701
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 100
at Pipeline->then(object(Closure)) in Router.php line 703
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 668
at Router->dispatchToRoute(object(Request)) in Router.php line 628
at Router->dispatch(object(Request)) in Kernel.php line 214
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 100
at Pipeline->then(object(Closure)) in Kernel.php line 115
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 52
at require_once('/home/mateus/Área de Trabalho/estoque/public/index.php') in server.php line 21

O que esta acontecendo? O que devo fazer?

2 respostas

você tem que instalar o driver do mysql:

sudo aptitude install php-mysql

ou

sudo apt-get install php-mysql

e reinicia o apache depois:

sudo /etc/init.d/apache2 restart

Depois de seguir a orientação do Alfredo, verifique se no arquivo php.ini apareceu a extensão do mysql, ou se for o caso abre o phpinfo().