Laravel'找不到驱动程序(SQL:插入...) [英] Laravel 'could not find driver (SQL: insert into...'

查看:292
本文介绍了Laravel'找不到驱动程序(SQL:插入...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一年多没有做Web开发之后,我正在尝试建立一个开发环境.我已经在计算机上安装了php 7.2.7,然后安装了作曲家和WAMP.

I'm trying to set up a development environment after not having done web dev in over a year. I've installed php 7.2.7 on my computer, then installed composer and WAMP.

我正在使用 php artisan serve 设置本地服务器.我正在尝试使用web.php(路由)文件中的以下代码在数据库的用户"表中创建新用户.

I'm using php artisan serve to set up a local server. I'm trying to create a new user in my database's 'users' table, using the following code in my web.php (routes) file.

Route::get('/new', function(){
  User::create([
    'password' => Hash::make('anything'),
    'firstname' => 'Nick',
    'lastname' => 'xyz',
    'email' => 'xyz@ph.com',
    'roleflag' => 0
  ]);
});

但是出现以下错误:

这似乎是一个非常常见的错误,我在其他stackoverflow/laracasts帖子中找到了帮助,例如:

This seems to be a pretty common error, and I have found help on other stackoverflow/laracasts posts such as:

Laravel:错误[PDOException]:找不到驱动程序在PostgreSQL中

https ://laracasts.com/discuss/channels/general-discussion/cant-connect-to-sql-server-could-not-find-driver

因此,我从php.ini文件中取消了两行注释,将.env和config/database.php文件更改为具有适当的设置/连接值等,但是仍然收到此错误.

I've thus uncommented the two lines from my php.ini file, changed my .env and config/database.php file to have appropriate settings/connection values, etc. but still receive this error.

相关的config.php代码:

Relevant config.php code:

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('venturebreeder', 'forge'),
    'username' => env('root', 'forge'),
    'password' => env('', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
],

自进行此操作已有一段时间以来,我的故障排除速度有所降低-有人能看到我做错了吗?非常感谢.

I'm a bit slower at troubleshooting since it has been a while since I've done this -- can anyone see what I'm doing wrong? Help much appreciated.

推荐答案

您在php.ini文件中取消了哪些注释?

What lines did you uncomment in php.ini file?

您是否安装了pdo_mysql扩展名?

Do you have the pdo_mysql extension installed?

;extension=pdo_mysql.so删除;并重新启动WAMP服务器

Remove the ; from ;extension=pdo_mysql.so and restart your WAMP server

来源: https://stackoverflow.com/a/35240511/6385459

这篇关于Laravel'找不到驱动程序(SQL:插入...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆