数据库一直连不上去,如何解决的?

Jacky.uelong

问题描述

安装了。php composer.phar require -W illuminate/database illuminate/pagination illuminate/events symfony/var-dumper 之后,数据库一直连不上去,如何解决的?

程序代码

$data['first'] = Db::table('ktv_customer')->where('customer_id', 1)->value('username');

报错信息

PDOException: could not find driver in F:\website\ktv.com\webman\vendor\illuminate\database\Connectors\Connector.php:70
Stack trace:
#0 F:\website\ktv.com\webman\vendor\illuminate\database\Connectors\Connector.php(70): PDO->__construct('mysql:host=127....', 'root', 'roottest', Array)
#1 F:\website\ktv.com\webman\vendor\illuminate\database\Connectors\Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=127....', 'root', 'roottest', Array)
#2 F:\website\ktv.com\webman\vendor\illuminate\database\Connectors\MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=127....', Array, Array)
#3 F:\website\ktv.com\webman\vendor\illuminate\database\Connectors\ConnectionFactory.php(184): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#5 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(1064): call_user_func(Object(Closure))
#6 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(1100): Illuminate\Database\Connection->getPdo()
#7 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(442): Illuminate\Database\Connection->getReadPdo()
#8 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(368): Illuminate\Database\Connection->getPdoForSelect(true)
#9 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(705): Illuminate\Database\Connection->Illuminate\Database\{closure}('select `usernam...', Array)
#10 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(672): Illuminate\Database\Connection->runQueryCallback('select `usernam...', Array, Object(Closure))
#11 F:\website\ktv.com\webman\vendor\illuminate\database\Connection.php(376): Illuminate\Database\Connection->run('select `usernam...', Array, Object(Closure))
#12 F:\website\ktv.com\webman\vendor\illuminate\database\Query\Builder.php(2414): Illuminate\Database\Connection->select('select `usernam...', Array, true)
#13 F:\website\ktv.com\webman\vendor\illuminate\database\Query\Builder.php(2402): Illuminate\Database\Query\Builder->runSelect()
#14 F:\website\ktv.com\webman\vendor\illuminate\database\Query\Builder.php(2936): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#15 F:\website\ktv.com\webman\vendor\illuminate\database\Query\Builder.php(2403): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#16 F:\website\ktv.com\webman\vendor\illuminate\database\Concerns\BuildsQueries.php(294): Illuminate\Database\Query\Builder->get(Array)
#17 F:\website\ktv.com\webman\vendor\illuminate\database\Query\Builder.php(2388): Illuminate\Database\Query\Builder->first(Array)
#18 F:\website\ktv.com\webman\app\controller\UserController.php(16): Illuminate\Database\Query\Builder->value('username')
#19 F:\website\ktv.com\webman\vendor\workerman\webman-framework\src\App.php(319): app\controller\UserController->login(Object(support\Request))
#20 F:\website\ktv.com\webman\vendor\workerman\webman-framework\src\App.php(560): Webman\App::Webman\{closure}(Object(support\Request))
#21 F:\website\ktv.com\webman\vendor\workerman\webman-framework\src\App.php(148): Webman\App::findRoute(Object(Workerman\Connection\TcpConnection), '/api/user/login', 'GET/api/user/lo...', Object(support\Request))
#22 F:\website\ktv.com\webman\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#23 F:\website\ktv.com\webman\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #156)
#24 F:\website\ktv.com\webman\vendor\workerman\workerman\Worker.php(1479): Workerman\Events\Select->loop()
#25 F:\website\ktv.com\webman\vendor\workerman\workerman\Worker.php(1399): Workerman\Worker::forkWorkersForWindows()
#26 F:\website\ktv.com\webman\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#27 F:\website\ktv.com\webman\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#28 F:\website\ktv.com\webman\start.php(4): support\App::run()
#29 {main}
699 2 0
2个回答

北月

pdo_mysql 驱动没有安装或者没有启用。

执行:php.exe -m 来查看已经安装并启用的扩展。

如果 php.exe 没有在环境变量中,则需要先进入 php.exe 所在目录,再执行 php.exe -m

xiaoming

提示这么明显 应该自己先看下

  • Jacky.uelong 2023-07-31

    因为,我发上去后,找不到删除按钮。哈哈。

年代过于久远,无法发表回答
×
🔝