PDO异常“找不到驱动程序”错误

问题描述 投票:0回答:1

我是Laravel新手。从最近的两天开始,我正尝试将数据库从laravel迁移到xampp。但是每次我收到PDO异常“找不到驱动程序”错误时。我收到2错误:

1 C:\xampp\htdocs\student\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   C:\xampp\htdocs\student\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=student", "root", "", [])


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

我在stackoverflow和许多其他网站上进行了搜索,并获得了许多解决方案,但它不适用于我。我仍然遇到这些错误。我还添加了我从多个stackoverflow解决方案中获得的所有必需扩展。但仍然无法正常工作。我随便附上代码。谁能帮助我找到我做错了什么?在此先感谢!

2020_06_04_052746_create_student_table.php

 public function up()
    {
        Schema::create('student', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email');
            $table->string('class');
            $table->int('pnumber');
            $table->timestamps();
        });
    }

php.ini

;
extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
extension=pdo_sqlite
;extension=pgsql
;extension=shmop
extension=php_pdo_mysql.dll
extension=php_mysql

。env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:v1jSrBPyR1wLOC96ePXWY0RRoTVuzNE3h+BB68RNqwI=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=student
DB_USERNAME=root
DB_PASSWORD=

执行php --ini命令后

Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File:         C:\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
php laravel laravel-5 pdo xampp
1个回答
0
投票

在Ubuntu / Debian中,您可以使用:

PHP5: sudo apt-get install php5-mysql
PHP7: sudo apt-get install php7.0-mysql

在Windows中转到php.ini,然后从这些行中将其删除:

extension=php_pdo.dll
extension=php_pdo_mysql.dll
OR:

extension=pdo.dll
extension=pdo_mysql.dll
© www.soinside.com 2019 - 2024. All rights reserved.