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

Erro ao conectar ao banco mysql

Boa tarde ja tentei tirar a senha e deixar apenas o "" mas não funcionou, usei a mesma senha da conexão do workbench. o erro

PHP Fatal error: Uncaught PDOException: could not find driver in C:\Users\pheli\OneDrive\Documentos\php\Banco\conection\conection.php:7 Stack trace:

#0 C:\Users\pheli\OneDrive\Documentos\php\Banco\conection\conection.php(7): PDO->__construct('mysql:host=loca...', 'root', 'narutoultimate1')

#1 {main} thrown in C:\Users\pheli\OneDrive\Documentos\php\Banco\conection\conection.php on line 7

Fatal error: Uncaught PDOException: could not find driver in C:\Users\pheli\OneDrive\Documentos\php\Banco\conection\conection.php:7 Stack trace:

#0 C:\Users\pheli\OneDrive\Documentos\php\Banco\conection\conection.php(7): PDO->__construct('mysql:host=loca...', 'root', 'narutoultimate1')

#1 {main} thrown in C:\Users\pheli\OneDrive\Documentos\php\Banco\conection\conection.php on line 7

suspeito que o erro ocorra pelo banco não estar "iniciado" apenas aberto no Workbench

o código

$connection = new PDO( 'mysql:host=localhost;dbname=banco', 'root', 'senhafullcomplexainvejadapelasegurancamundial' );

2 respostas

Phelipe

*PHP Fatal error: Uncaught PDOException: could not find driver *

Reveja se o módulo pdo_mysql está instalado e ativo. execute *php -i *

ou em algum php: <?php phpinfo(); ?>

Você está usando docker, vagrant ou servidor local?

Atenciosamente Léo Moraes

solução!

Veja esta reposta solucionada sobre o mesmo assunto https://cursos.alura.com.br/forum/topico-primeira-conexao-com-o-pdo-68116

Por favor, se resolver, marque esta conversa como solucionado.

Atenciosamente Léo Moraes

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software