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初学者们头痛的十四个问题
Jan 15 PHP
php下通过伪造http头破解防盗链的代码
Jul 03 PHP
PHP操作MongoDB GridFS 存储文件的详解
Jun 20 PHP
PHP中使用strpos函数实现屏蔽敏感关键字功能
Aug 21 PHP
为你总结一些php系统类函数
Oct 21 PHP
orm获取关联表里的属性值
Apr 17 PHP
php+MySQL实现登录时验证登录名和密码是否正确
May 10 PHP
PHP实现的登录,注册及密码修改功能分析
Nov 25 PHP
PHP数据库处理封装类实例
Dec 24 PHP
PHP数据分析引擎计算余弦相似度算法示例
Aug 08 PHP
Laravel中前端js上传图片到七牛云的示例代码
Sep 04 PHP
php中pcntl_fork详解
Apr 01 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
用PHP实现ODBC数据分页显示一例
2006/10/09 PHP
php文件服务实现虚拟挂载其他目录示例
2014/04/17 PHP
浅析Yii2 GridView实现下拉搜索教程
2016/04/22 PHP
解决微信授权回调页面域名只能设置一个的问题
2016/12/11 PHP
js 获取浏览器高度和宽度值(多浏览器)
2009/09/02 Javascript
通过js获取div的background-image属性
2013/10/15 Javascript
Javascript中的匿名函数与封装介绍
2015/03/15 Javascript
基于jQuery实现的无刷新表格分页实例
2016/02/17 Javascript
JavaScript根据CSS的Media Queries来判断浏览设备的方法
2016/05/10 Javascript
Vue.js项目部署到服务器的详细步骤
2017/07/17 Javascript
vscode下的vue文件格式化问题
2018/11/28 Javascript
vue-cli3 引入 font-awesome的操作
2020/08/11 Javascript
通过实例解析JavaScript常用排序算法
2020/09/02 Javascript
使用JS实现鼠标放上图片进行放大离开实现缩小功能
2021/01/27 Javascript
python3 与python2 异常处理的区别与联系
2016/06/19 Python
python的scikit-learn将特征转成one-hot特征的方法
2018/07/10 Python
python面试题小结附答案实例代码
2019/04/11 Python
python腾讯语音合成实现过程解析
2019/08/01 Python
Django发送邮件和itsdangerous模块的配合使用解析
2019/08/10 Python
Python上下文管理器全实例详解
2019/11/12 Python
Python3 A*寻路算法实现方式
2019/12/24 Python
Python IDE环境之 新版Pycharm安装详细教程
2020/03/05 Python
python excel多行合并的方法
2020/12/09 Python
美国演唱会和体育门票购买网站:Ticketnetwork
2018/10/19 全球购物
Regatta官网:英国最受欢迎的户外服装和鞋类品牌
2019/05/01 全球购物
编辑硕士自荐信范文
2013/11/27 职场文书
入党申请自荐书范文
2014/02/11 职场文书
警校毕业生自我评价
2014/04/06 职场文书
领导班子“四风问题”“整改方案
2014/10/02 职场文书
交通安全横幅标语
2014/10/07 职场文书
党员群众路线教育实践活动学习笔记
2014/11/05 职场文书
新学期开学寄语2016
2015/12/04 职场文书
七年级写作指导之游记作文
2019/10/07 职场文书
Axios代理配置及封装响应拦截处理方式
2022/04/07 Vue.js
SQL解决未能删除约束问题drop constraint
2022/05/30 SQL Server
redis lua限流算法实现示例
2022/07/15 Redis