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 相关文章推荐
我的论坛源代码(九)
Oct 09 PHP
PHP安装攻略:常见问题解答(二)
Oct 09 PHP
下载文件的点击数回填
Oct 09 PHP
如何利用PHP执行.SQL文件
Jul 05 PHP
php中的静态变量的基本用法
Mar 20 PHP
ThinkPHP标签制作教程
Jul 10 PHP
11个PHPer必须要了解的编程规范
Sep 22 PHP
反射调用private方法实践(php、java)
Dec 21 PHP
PHP实现动态获取函数参数的方法示例
Apr 02 PHP
php 中phar包的使用教程详解
Oct 26 PHP
phpStorm+XDebug+chrome 配置详解
Apr 01 PHP
Yii 实现数据加密和解密
Mar 09 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
PHP4实际应用经验篇(8)
2006/10/09 PHP
PHP 和 XML: 使用expat函数(一)
2006/10/09 PHP
php+jQuery实现的三级导航栏下拉菜单显示效果
2017/08/10 PHP
让innerHTML的脚本也可以运行起来
2006/07/01 Javascript
Javascript实例教程(19) 使用HoTMetal(1)
2006/12/23 Javascript
javascript静态的url如何传递
2007/05/03 Javascript
jquery异步跨域访问代码
2013/06/28 Javascript
jquery模拟alert的弹窗插件
2015/07/31 Javascript
JavaScript操作URL的相关内容集锦
2015/10/29 Javascript
JS中如何比较两个Json对象是否相等实例代码
2016/07/13 Javascript
AngularJS基础 ng-disabled 指令详解及简单示例
2016/08/01 Javascript
JavaScript和jQuery获取input框的绝对位置实现方法
2016/10/13 Javascript
微信小程序tabbar不显示解决办法
2017/06/08 Javascript
vue中子组件的methods中获取到props中的值方法
2018/08/27 Javascript
Node.js npm命令运行node.js脚本的方法
2018/10/10 Javascript
如何在Vue中抽离接口配置文件
2019/10/31 Javascript
JS实现随机抽选获奖者
2019/11/07 Javascript
vue 组件间的通信之子组件向父组件传值的方式
2020/07/29 Javascript
Python 编码处理-str与Unicode的区别
2016/09/06 Python
python如何实现内容写在图片上
2018/03/23 Python
Pandas中Series和DataFrame的索引实现
2019/06/27 Python
Python warning警告出现的原因及忽略方法
2020/01/31 Python
opencv+python实现均值滤波
2020/02/19 Python
html5 Canvas实现图片旋转的示例
2018/01/15 HTML / CSS
Html5让容器充满屏幕高度或自适应剩余高度的布局实现
2020/05/14 HTML / CSS
英国香水店:The Perfume Shop
2017/03/27 全球购物
舞蹈教师自荐信
2014/01/27 职场文书
电大会计学自我鉴定
2014/02/06 职场文书
小学毕业感言300字
2014/02/19 职场文书
租赁意向书范本
2014/04/01 职场文书
校外活动方案
2014/08/28 职场文书
网站出售协议书范文
2014/10/10 职场文书
道德与公民自我评价
2015/03/09 职场文书
教你怎么用Python监控愉客行车程
2021/04/29 Python
Java Optional<Foo>转换成List<Bar>的实例方法
2021/06/20 Java/Android
JavaScript parseInt0.0000005打印5原理解析
2022/07/23 Javascript