温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用laravel执行php时出现artisan migrate报错如何解决

发布时间:2021-05-24 16:27:46 来源:亿速云 阅读:506 作者:Leah 栏目:开发技术

使用laravel执行php时出现artisan migrate报错如何解决?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

报错一

$ php artisan migrate
 
 Illuminate\Database\QueryException : could not find driver (SQL: select * fr
om information_schema.tables where table_schema = dev_oms and table_name = migra
tions)
 
 at D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection.
php:664
 660|   // If an exception occurs when attempting to run a query, we'll
 format the error
 661|   // message to include the bindings with SQL, which will make th
is exception a
 662|   // lot more helpful to the developer instead of just the databa
se's errors.
 663|   catch (Exception $e) {
 > 664|    throw new QueryException(
 665|     $query, $this->prepareBindings($bindings), $e
 666|    );
 667|   }
 668|
 
 Exception trace:
 
 1 PDOException::("could not find driver")
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connectors
\Connector.php:68
 
 2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=dev_oms", "root",
"root", [])
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connectors
\Connector.php:68
 
 Please use the argument -v to see more details.

原因是php.ini 扩展"php_pdo_mysql.dll"没开启

使用laravel执行php时出现artisan migrate报错如何解决

报错二

$ php artisan migrate
Migration table created successfully.
 
 Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access
 violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: a
lter table `users` add unique `users_email_unique`(`email`))
 
 at D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection.
php:664
 660|   // If an exception occurs when attempting to run a query, we'll
 format the error
 661|   // message to include the bindings with SQL, which will make th
is exception a
 662|   // lot more helpful to the developer instead of just the databa
se's errors.
 663|   catch (Exception $e) {
 > 664|    throw new QueryException(
 665|     $query, $this->prepareBindings($bindings), $e
 666|    );
 667|   }
 668|
 Exception trace:
 1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Sp
ecified key was too long; max key length is 767 bytes")
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 2 PDOStatement::execute()
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 Please use the argument -v to see more details.

数据库编码改为utf8mb4

使用laravel执行php时出现artisan migrate报错如何解决

报错三

$ php artisan migrate
Migration table created successfully.
 
 Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access
 violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: a
lter table `users` add unique `users_email_unique`(`email`))
 
 at D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection.
php:664
 660|   // If an exception occurs when attempting to run a query, we'll
 format the error
 661|   // message to include the bindings with SQL, which will make th
is exception a
 662|   // lot more helpful to the developer instead of just the databa
se's errors.
 663|   catch (Exception $e) {
 > 664|    throw new QueryException(
 665|     $query, $this->prepareBindings($bindings), $e
 666|    );
 667|   }
 668|
 Exception trace:
 1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Sp
ecified key was too long; max key length is 767 bytes")
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 2 PDOStatement::execute()
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 Please use the argument -v to see more details.

加上两行代码即可

使用laravel执行php时出现artisan migrate报错如何解决

Laravel 是什么

Laravel 是一套简洁、优雅的PHP Web开发框架。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。

关于使用laravel执行php时出现artisan migrate报错如何解决问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI