我安装了Laravel并从我的git服务器克隆了一个repo,用于登台服务器。安装完所有必需的工具后,我想迁移数据库。我现在得到的错误是:
[2016-05-04 16:54:51] local.ERROR:异常'PDOException'用 消息“无法找到驱动程序” /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:55
#1 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(22): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=46.1...', Array, Array)
#2 /var/www/mfserver/bootstrap/cache/compiled.php(11439): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3 /var/www/mfserver/bootstrap/cache/compiled.php(11435): Illuminate\Database\Connectors\ConnectionFactory->createSingleConnection(Array)
#4 /var/www/mfserver/bootstrap/cache/compiled.php(11350): Illuminate\Database\Connectors\ConnectionFactory->make(Array, 'mysql')
#5 /var/www/mfserver/bootstrap/cache/compiled.php(11305): Illuminate\Database\DatabaseManager->makeConnection('mysql')
#6 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(171): Illuminate\Database\DatabaseManager->connection(NULL)
#7 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(139): Illuminate\Database\Migrations\DatabaseMigrationRepository->getConnection()
#8 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(393): Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()
#9 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(100): Illuminate\Database\Migrations\Migrator->repositoryExists()
#10 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(58): Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase()
#11 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#12 /var/www/mfserver/bootstrap/cache/compiled.php(1187): call_user_func_array(Array, Array)
#13 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Console/Command.php(150): Illuminate\Container\Container->call(Array)
#14 /var/www/mfserver/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/mfserver/vendor/symfony/console/Application.php(841): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/mfserver/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/mfserver/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/mfserver/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
我安装了php-mysql,但我不明白为什么缺少驱动程序。
答案 0 :(得分:0)
我在 Win 8.1机器(64位)中遇到了同样的问题,我根据stackoverflow中的其他答案尝试了几乎所有可能的修复。最后它解决但我不知道哪个修复解决了我的问题。我已经做了以下事情来解决这个问题。
将php.ini文件作为phpForApache.ini复制并粘贴到我的php7的同一目录中(仍然不能正常工作)
composer卸载并再次安装最新的php7,因为它的php路径(仍然不能正常工作)
php artisan migrate
查询(现在可以正常工作)我仍然不知道哪个步骤可以解决我的问题,可能你可以尝试所有这些步骤。