gpt4 book ai didi

php - 找不到驱动程序

转载 作者:行者123 更新时间:2023-11-29 16:15:28 25 4
gpt4 key购买 nike

我将项目从旧主机移至新主机我尝试了几次,但每次尝试时,Laravel 都会显示此错误:

could not find driver (SQL: select * from orders where status not in (PENDING, COMPLETED) and api_order_id is not null order by RAND() limit 15)

我确信我已完全上传我的数据库并且我正确地输入了我的数据库信息那么为什么会出现这个错误呢?

Config/database.php代码:

<?php

return [

/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/

'fetch' => PDO::FETCH_OBJ,

/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/

'default' => env('DB_CONNECTION', 'mysql'),

/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/

'connections' => [

'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],

'mysql' => [
'driver' => 'mysql',
'port' => env('DB_PORT', '3306'),
'host' => 'localhost',
'database' => 'my_db_name',
'username' => 'db_user',
'password' => 'db_pass',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'modes' => [
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_CREATE_USER',
'NO_ENGINE_SUBSTITUTION'
]
],

'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],

],

/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/

'migrations' => 'migrations',

/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/

'redis' => [

'cluster' => false,

'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],

],

'installed' => '1',
'transfer_mode' => '%transfer_mode%',
];

.env 文件代码:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_db_name
DB_USERNAME=db_user
DB_PASSWORD=db_pass

最佳答案

MySQL 是数据库,php 使用 pdo_mysql 等扩展来连接 PHP 和 MySQL。首先驱动程序和扩展是不同的。驱动程序是mysqlndmysqlnd,而扩展程序是pdo_mysqlnd_pdo_mysql等。首先检查驱动程序是否安装正确。

检查扩展名的步骤:

  1. 检查 phpinfo() 是否看到 pdo_mysql 已启用。
  2. 有时,托管主机(主要是带有 cpanel 的托管主机)默认启用 sql 扩展。在 phpinto 中检查 php 扩展部分中的 _mysql。检查是否看到启用了任何其他扩展,例如 nd_pdo_mysql 。如果是这种情况,那么您会注意到冲突。您需要先禁用它,然后再次尝试启用 pdo_mysql
  3. 重新启动您的 PHP 服务,如果有效,您可以重试。

关于php - 找不到驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54843554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com