我是Laravel的新手,正在尝试跟随在线教程。我到了需要在终端上运行php artisan migrate
的地步,并收到以下错误:
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = some_db and table_name = migrations and table_type = 'BASE TABLE')
at C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
1 C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("could not find driver")
2 C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=some_db", "root", "", [])
我已经尝试了所有可以在此处找到的解决方案,并且进入了php.ini
文件以启用不同的扩展名,但是似乎没有任何效果。我找到了说可以尝试运行sudo apt-get install php-mysql
的解决方案,但是我使用的是Windows,因此这不是我的选择。在此问题上的任何帮助将不胜感激!
答案 0 :(得分:0)
如果已经安装了mysql驱动程序,则应确保在.ENV文件中分配了以下变量// Si yatienes el controlador para mysql instalado,debes asegurarte que en el archivo .ENVesténlas siguientes variable asignadas:
DB_CONNECTION=mysql //mysql driver
DB_HOST=127.0.0.1 //connection host
DB_PORT=3306 //mysql port
DB_DATABASE=laravel //database name
DB_USERNAME=root //database user
DB_PASSWORD= //database password
答案 1 :(得分:0)
在您的php.ini配置文件中,只需取消注释扩展名即可:
;extension=php_pdo_mysql.dll
(您可以在安装堆栈服务器的php文件夹中找到php.ini文件。)
如果您使用的是 Windows ,请执行以下操作:extension = php_pdo_mysql.dll
如果您使用的是Linux,请执行以下操作:extension = pdo_mysql.so
并快速重启服务器。
如果这不适用于您,则可能需要将pdo_mysql扩展安装到您的php库中。