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

 更新时间:2019年10月09日 09:50:59   作者:_吴慧良  
今天小编就为大家分享一篇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"没开启

报错二

$ 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

报错三

$ 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报错的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • PHP函数引用返回的实例详解

    PHP函数引用返回的实例详解

    其实PHP函数引用与php中变量引用一样,都使用的是&符号了,那么今天我们就一起来看看函数的引用返回的一些例子,有需要的朋友们可以参考借鉴,下面来一起看看吧。
    2016-09-09
  • ThinkPHP之用户注册登录留言完整实例

    ThinkPHP之用户注册登录留言完整实例

    这篇文章主要介绍了ThinkPHP之用户注册登录留言完整实例,有助于详细了解ThinkPHP的运作流程,需要的朋友可以参考下
    2014-07-07
  • 在laravel框架中使用model层的方法

    在laravel框架中使用model层的方法

    今天小编就为大家分享一篇在laravel框架中使用model层的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-10-10
  • php生成静态html页面的方法(2种方法)

    php生成静态html页面的方法(2种方法)

    在PHP网站开发中为了网站推广和SEO等需要,需要对网站进行全站或局部静态化处理,PHP生成静态HTML页面有多种方法,比如利用PHP模板、ob系列的函数,本文给大家分享php生成静态html页面的方法(2种方法),感兴趣的朋友跟着小编一起学习学习吧
    2015-09-09
  • laravel validate 设置为中文的例子(验证提示为中文)

    laravel validate 设置为中文的例子(验证提示为中文)

    今天小编就为大家分享一篇laravel validate 设置为中文的例子(验证提示为中文),具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-09-09
  • PHP将amr音频文件转换为mp3格式的操作细节

    PHP将amr音频文件转换为mp3格式的操作细节

    本文以centos服务器安装ffmpeg为例,给大家详细介绍PHP将amr音频文件转换为mp3格式的操作细节,感兴趣的朋友跟随小编一起看看吧
    2021-07-07
  • Laravel接收前端ajax传来的数据的实例代码

    Laravel接收前端ajax传来的数据的实例代码

    本篇文章主要介绍了Laravel接收前端ajax传来的数据的实例代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
    2017-07-07
  • PHP 布尔值的自增与自减的实现方法

    PHP 布尔值的自增与自减的实现方法

    这篇文章主要介绍了PHP 布尔值的自增与自减的实现方法,非常不错,具有参考借鉴价值,需要的朋友参考下吧
    2018-05-05
  • PHP代码判断设备是手机还是平板电脑(两种方法)

    PHP代码判断设备是手机还是平板电脑(两种方法)

    随着互联网移动设备的普及,很多网站都兼容手机端浏览,为了更好的让网页在手机端显示,我们都选择了使用CSS媒体查询制作响应式模版。本文给大家介绍PHP代码判断设备是手机还是平板电脑(两种方法),感兴趣的朋友一起学习吧
    2015-10-10
  • 浅谈PHP中pack、unpack的详细用法

    浅谈PHP中pack、unpack的详细用法

    这篇文章主要介绍了浅谈PHP中pack、unpack的详细用法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-03-03

最新评论