laravel9.38.0中执行php artisan migrate提示could not find driver

如题,运行php artisan migrate导入数据库到mysql时,报了错误:

C:\Users\Administrator\Downloads\laravel9.38.0>php artisan migrate

   Illuminate\Database\QueryException

  could not find driver (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

  at C:\Users\Administrator\Downloads\laravel9.38.0\vendor\laravel\framework\src\Illuminate\Database\Connection.php:760    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

  1   C:\Users\Administrator\Downloads\laravel9.38.0\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   C:\Users\Administrator\Downloads\laravel9.38.0\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])

这种问题实际上是php中没有配置mysql插件导致的。php连接mysql的驱动程序有两种:MySQLi 和 PDO,你只需要在配置文件php.ini中将它启用,由于上面的报错是没有启用PDO扩展导致的,这里将“;extension=pdo_mysql”一行前面的分号去掉即可。

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值