美文网首页
解决could not find driver错误。

解决could not find driver错误。

作者: liurongming | 来源:发表于2024-01-12 14:01 被阅读0次
    • php版本:
    php -v
    PHP 8.3.1 (cli) (built: Dec 20 2023 14:06:10) (ZTS Visual C++ 2019 x64)
    Copyright (c) The PHP Group
    Zend Engine v4.3.1, Copyright (c) Zend Technologies
    
    • laravel版本:
    php artisan --version
    Laravel Framework 10.40.0
    
    • 问题:
     php artisan migrate
    
       Illuminate\Database\QueryException
    
      could not find driver (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'rw_shop' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
    
      at vendor\laravel\framework\src\Illuminate\Database\Connection.php:822
        818▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
        819▕                 );
        820▕             }
        821▕
      ➜ 822▕             throw new QueryException(
        823▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
        824▕             );
        825▕         }
        826▕     }
    
      1   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:65
          PDOException::("could not find driver")
    
      2   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:65
          PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=rw_shop", "rw_shop", Object(SensitiveParameterValue), [])
    
    

    解决:
    在php安装目录下,增加文件php.ini,添加mysql相关驱动即可。
    如:extension=php_pdo_mysql和extension=php_openssl.dll
    配置参考:

    [Date]
    date.timezone=Asia/Shanghai
    [PHP]
    max_execution_time = 300
    max_input_time=60
    max_input_vars=3000
    memory_limit=256M
    upload_max_filesize = 100M
    post_max_size = 100M
    max_file_uploads = 100
    display_errors = On
    display_startup_errors=On
    log_errors=On
    track_errors=Off
    html_errors=On
    error_log=C:/phpstudy_pro/Extensions/php/php-8.3.1-Win32-vs16-x64.log
    error_reporting=E_ALL & ~E_NOTICE
    allow_url_fopen=On
    allow_url_include=Off
    extension_dir="C:\phpstudy_pro\Extensions\php\php-8.3.1-Win32-vs16-x64\ext"
    extension=php_pdo_mysql
    extension=php_openssl.dll
    extension=zip
    extension=curl
    variables_order = "GPCS"
    

    至此,解决完毕。

    相关文章

      网友评论

          本文标题:解决could not find driver错误。

          本文链接:https://www.haomeiwen.com/subject/ddvxodtx.html