Php Laravel迁移找不到驱动程序
当我试图让Php Laravel迁移找不到驱动程序,php,laravel,mysql-connector,Php,Laravel,Mysql Connector,当我试图让php artisan迁移时,我出现了这个错误 Illuminate\Database\QueryException could not find driver (SQL: select * from information_schema.tables where table_schema = lsapp and table_name = migrations and table_type = 'BASE TABLE') at vendor/laravel/fra
php artisan迁移时,我出现了这个错误
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = lsapp and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
+34 vendor frames
35 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
我已经在phpmyadmin上创建了数据库。下面是my.env文件的配置
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=lsapp
DB_USERNAME=root
DB_PASSWORD=
这里是myconfig/database.php中mysql的配置
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'lsapp'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
]
帮助我解决这个问题您可以检查php.ini
文件中是否激活了pdo_mysql
扩展名。在php.ini配置文件中取消对扩展名的注释,删除代码>:
extension=php_pdo_mysql.dll
如果您使用的是Linux,请执行以下操作:
extension=pdo_mysql.so
然后重新启动服务器
如果这对您不起作用,您可能需要在php库中安装pdo_mysql扩展。可能是您正在使用两个或更多版本的php。所以你最好:
sudo apt安装php mysql
通过这种方式,您可以确保每个版本上都安装了pdo_mysql
扩展
在此之后,只需重新启动apache2:sudo systemctl restart apache2
我删除了代码>在我的/etc/php/7.3/apache2/php.ini文件中,但它做的是相同的事情我的计算机中有两个版本的php,我在两个文件夹(7.2和7.3)中修改了php.ini,但它做的是相同的thing@Etali修改php.ini文件后,需要重新启动服务器/apache问题是我编辑了错误的php.ini文件,我需要编辑的php.ini文件位于我的服务器位置(/opt/lampp/etc)。感谢您的帮助sudo-apt-install-php-mysql
这在删除php并重新安装php后对我有所帮助。