laravel执行php artisan migrate报错的解决方法
作者:_吴慧良 时间:2024-06-05 09:44:39
报错一
$ 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.
加上两行代码即可
来源:https://blog.csdn.net/Code_Pupil/article/details/80371145
标签:laravel,php,artisan,migrate
0
投稿
猜你喜欢
间歇向上无缝翻滚代码
2008-05-05 12:30:00
Python代码库之Tuple如何append添加元素问题
2021-10-02 07:13:34
Python3接口性能测试实例代码
2021-02-16 14:24:18
纯CSS Tooltips提示
2008-10-18 16:01:00
设计模式-自动完成
2010-11-30 21:44:00
Python Django搭建文件下载服务器的实现
2021-06-04 14:37:55
JavaScript实现复制内容到粘贴板代码
2024-04-25 13:14:01
js实现复选框的全选和取消全选效果
2024-05-02 17:40:02
python3利用ctypes传入一个字符串类型的列表方法
2021-06-10 20:33:36
python简单实现基数排序算法
2023-11-10 06:27:27
JavaScript中利用构造器函数模拟类的方法
2023-07-02 05:30:13
C#使用ODBC与OLEDB连接数据库的方法示例
2024-01-12 17:41:41
Python 启动时选择32位 或64位版的操作
2021-04-29 23:50:43
mysql如何跨时区迁移数据
2010-03-25 10:26:00
大数据就业的三大方向和最热门十大岗位【推荐】
2023-05-18 16:21:06
Mysql存储过程学习笔记--建立简单的存储过程
2024-01-23 14:41:21
Python中Continue语句的用法的举例详解
2023-04-04 13:12:37
MySQL插入时间差八小时问题的解决方法
2024-01-28 22:00:09
解决python文件字符串转列表时遇到空行的问题
2021-06-27 09:18:25
Git中使用.gitignore忽略文件的推送方式
2023-03-03 21:53:59