php artisan db:seed时,出现错误
来源:4-6 项目导入运行的步骤

忍者阿龙
2021-03-27
老师好,我下完mcshop的代码后,根据视频教程,在执行
php artisan db:seed时,出现以下错误
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667▕ // If an exception occurs when attempting to run a query, we'll format the error
668▕ // message to include the bindings with SQL, which will make this exception a
669▕ // lot more helpful to the developer instead of just the database's errors.
670▕ catch (Exception $e) {
➜ 671▕ throw new QueryException(
672▕ $query, $this->prepareBindings($bindings), $e
673▕ );
674▕ }
675▕
+16 vendor frames
17 database/seeders/DatabaseSeeder.php:17
Illuminate\Support\Facades\Facade::__callStatic("unprepared")
+22 vendor frames
40 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
试着更改DB密码,用户名,
都不能解决问题.
这是什么问题呢?
写回答
1回答
-
忍者阿龙
提问者
2021-03-27
我好像找到原因了.
\mcshop\database\seeders\litemall_db.sql
这个文件是dump文件,所以需要执行以下命令:
php artisan migrate:fresh --seed
如果是第一次的话,还需要先登入到mysql.创建litemall数据库.在执行上述命令.
如果出现user错误,只需要把.env里面的用户名和密码改为root就ok了
112021-03-28
相似问题