Solucionado (ver solução)
Solucionado
(ver solução)
6
respostas

Erro ao tentar php artisan migrate

Illuminate\Database\QueryException  : could not find driver (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')

  at /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("could not find driver")
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=forge", "forge", "", [])
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  Please use the argument -v to see more details.

uso manjaro arch linux. Oq devo fazer?

6 respostas

Olá, Marília.

Como você instalou o PHP?

Você precisa habilitar a extensão pdo_mysql, já que está utilizando o MySQL como banco de dados.

Dependendo de como foi feita a instalação do PHP, basta descomentar no php.ini a linha extension=php_mysql.

Caso só isso não resolva, você pode ver como instalar extensões no PHP aqui: https://www.php.net/manual/pt_BR/ref.pdo-mysql.php

"The common Unix distributions include binary versions of PHP that can be installed. Although these binary versions are typically built with support for the MySQL extensions, the extension libraries themselves may need to be installed using an additional package. Check the package manager than comes with your chosen distribution for availability.

For example, on Ubuntu the php5-mysql package installs the ext/mysql, ext/mysqli, and PDO_MYSQL PHP extensions. On CentOS, the php-mysql package also installs these three PHP extensions."

Ou seja, se você instalou o PHP diretamente com o pacman, muito provavelmente só precisará habilitar a extensão no php.ini.

Ah... Para descobrir onde está o php.ini:

$ php -i | grep "php.ini"

PS. Eu estou querendo usar o SQLite. PS2. eu instalei o php........... nao lembro. Devo reinstalar?

Descomento o pdo mysql e o serve roda normal, mas nao consegue fazer o migrate. Entao descomentei ambos pdo mysql e pdo sqlite pra ver noq q dava e deu:

[marilia@marilia-pc crud_rbarcos]$ php artisan serve
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib/php/modules/pdo_sqlite (/usr/lib/php/modules/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib/php/modules/pdo_sqlite.so (/usr/lib/php/modules/pdo_sqlite.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Laravel development server started: <http://127.0.0.1:8000>
[Wed May 29 18:25:45 2019] PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib/php/modules/pdo_sqlite (/usr/lib/php/modules/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib/php/modules/pdo_sqlite.so (/usr/lib/php/modules/pdo_sqlite.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Wed May 29 18:25:54 2019] 127.0.0.1:59238 [200]: /favicon.ico

na hora de migrar:

 Illuminate\Database\QueryException  : could not find driver (SQL: PRAGMA foreign_keys = ON;)

  at /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("could not find driver")
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("sqlite:/home/marilia/projetos/prova_rbarcos/crud_rbarcos/database/database.sqlite", [])
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  Please use the argument -v to see more details.

   Whoops\Exception\ErrorException  : PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib/php/modules/pdo_sqlite (/usr/lib/php/modules/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib/php/modules/pdo_sqlite.so (/usr/lib/php/modules/pdo_sqlite.so: cannot open shared object file: No such file or directory))

  at Unknown:0
    1| 

"basta descomentar no php.ini a linha extension=php_mysql." nao tem essa extensao no meu. Essas sao as extensoes PDO no meu php.ini

;extension=pdo_dblib
;extension=pdo_mysql
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite

entao deixo so o pdo mysql descomentado e na hora de fazer a migraçao:

 Illuminate\Database\QueryException  : could not find driver (SQL: PRAGMA foreign_keys = ON;)

  at /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("could not find driver")
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("sqlite:/home/marilia/projetos/prova_rbarcos/crud_rbarcos/database/database.sqlite", [])
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  Please use the argument -v to see more details.

to mais perdida q cego em tiroteio

No arquivo .env estava sqlite, editei para mysql:

DB_CONNECTION=mysql
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=homestead
#DB_USERNAME=homestead
#DB_PASSWORD=secret

tentei fazer o migrate, e deu isso:


   Illuminate\Database\QueryException  : SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')

  at /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)")
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=forge", "forge", "", [])
      /home/marilia/projetos/prova_rbarcos/crud_rbarcos/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  Please use the argument -v to see more details.

Calma, Marília. Vamos por partes.

Volta o .env pra SQLite e descomenta a linha do pdo_sqlite apenas.

O que acontece nesse caso?

solução!

hey amigooo, professor lindo, excelente curso e didática. Desculpa o desespero ontem. Eu continuei com o MySQL, descomentei o pdo_mysql e segui em frente. O problema estava em: eu nao tinha criado um banco!!! Tem que criar um banco, informar o nome do banco no .env, e depois fazer o migrate que da tudo certo!! =)

Hahahaha

Obrigado pelo feedback (e mais ainda pelo "lindo" hahah).

Sem problemas continuar com o MySQL. Como utilizamos o Eloquent (ORM), não vai ter problema nenhum.

;-)

Bons estudos.