laravel执行php artisan migrate报错的解决方法


Posted in PHP onOctober 09, 2019

报错一

$ 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执行php artisan migrate报错的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

PHP 相关文章推荐
PHP+.htaccess实现全站静态HTML文件GZIP压缩传输(一)
Feb 15 PHP
攻克CakePHP系列一 连接MySQL数据库
Oct 22 PHP
PHP strtr() 函数使用说明
Nov 21 PHP
一步一步学习PHP(7) php 字符串相关应用
Mar 05 PHP
php 使用post,get的一种简洁方式
Apr 25 PHP
PHP中使用gettext来支持多语言的方法
May 02 PHP
hadoop中一些常用的命令介绍
Jun 19 PHP
php获取apk包信息的方法
Aug 15 PHP
PHP图片库imagemagick安装方法
Sep 23 PHP
PHP使用array_fill定义多维数组的方法
Mar 18 PHP
php生成圆角图片的方法
Apr 07 PHP
Laravel框架基于中间件实现禁止未登录用户访问页面功能示例
Jan 17 PHP
解决Laravel 不能创建 migration 的问题
Oct 09 #PHP
Laravel创建数据库表结构的例子
Oct 09 #PHP
关于laravel 数据库迁移中integer类型是无法指定长度的问题
Oct 09 #PHP
Laravel 创建指定表 migrate的例子
Oct 09 #PHP
laravel批量生成假数据的方法
Oct 09 #PHP
解决laravel5中auth用户登录其他页面获取不到登录信息的问题
Oct 08 #PHP
对laravel的session获取与存取方法详解
Oct 08 #PHP
You might like
索尼SONY ICF-SW7600GR电路分析与改良
2021/03/02 无线电
解析数组非数字键名引号的必要性
2013/08/09 PHP
php中unserialize返回false的解决方法
2014/09/22 PHP
PHP实现的字符串匹配算法示例【sunday算法】
2017/12/19 PHP
php 使用expat方式解析xml文件操作示例
2019/11/26 PHP
PHP获取真实IP及IP模拟方法解析
2020/11/24 PHP
理解Javascript_03_javascript全局观
2010/10/11 Javascript
Javascript 命名空间模式
2013/11/01 Javascript
JavaScript函数的一些注意要点小结及js匿名函数
2015/11/10 Javascript
JS实现上下左右对称的九九乘法表
2016/02/22 Javascript
JavaScript实现图片滑动切换的代码示例分享
2016/03/06 Javascript
Bootstrap导航条可点击和鼠标悬停显示下拉菜单的实现代码
2016/06/23 Javascript
vue项目中使用lib-flexible解决移动端适配的问题解决
2018/08/23 Javascript
JavaScript JMap类定义与使用方法示例
2019/01/22 Javascript
vue自定义指令用法经典实例小结
2019/03/16 Javascript
JavaScript中常用的3种弹出提示框(alert、confirm、prompt)
2020/11/10 Javascript
原生js实现自定义滚动条
2021/01/20 Javascript
[02:52]2017DOTA2国际邀请赛中国区预选赛晋级之路
2017/07/03 DOTA
使用Python内置的模块与函数进行不同进制的数的转换
2016/03/12 Python
Linux下为不同版本python安装第三方库
2016/08/31 Python
python使用正则表达式匹配字符串开头并打印示例
2017/01/11 Python
python3连接MySQL数据库实例详解
2018/05/24 Python
Python不同目录间进行模块调用的实现方法
2019/01/29 Python
Django搭建项目实战与避坑细节详解
2020/12/06 Python
css 如何让背景图片拉伸填充避免重复显示
2013/07/11 HTML / CSS
Farfetch香港官网:汇集全球时尚奢侈品购物平台
2017/11/26 全球购物
自然健康的概念:Natural Healthy Concepts
2020/01/26 全球购物
全球最受追捧的运动服品牌领先数字目的地:Stylerunner
2020/11/25 全球购物
大学本科生的个人自我评价
2013/12/09 职场文书
教师职位说明书
2014/07/29 职场文书
大学生党员批评与自我批评范文
2014/10/14 职场文书
大学生个人总结范文
2015/02/15 职场文书
兼职安全员岗位职责
2015/02/15 职场文书
军训阅兵新闻稿
2015/07/17 职场文书
交通事故协议书范本
2016/03/19 职场文书
关于企业的执行力标语大全
2020/01/06 职场文书