- 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相關(guān)驅(qū)動即可场绿。
如:extension=php_pdo_mysq
l和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"
至此,解決完畢嫉入。