最近在安装某基于LarAvel的PHP的程序的时候,在安装的过程中老是报错,网上给出的很多解决方案基本无效,经过研究,本文将详细的解决方案以及步骤写出来和大家分享!
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `comments` add index `comments_commenter_id_commenter_type_index`(`commenter_id`, `commenter_type`))
解决方案如下:
1、转到/config/database.php并找到下面的语句
'Mysql' => [ ..., 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', ..., 'engine' => null, ]
并将它们更改为:
'mysql' => [ ..., 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ..., 'engine' => 'InnoDB', ]
同时你也应该保证你的字符集为:utf8;排序规则为:utf8_unicode_ci,如下图所示:
2、运行命令行php artisan config:cache重新配置 laRavel,如下图所示:
3、删除数据库中现有的表,然后运行命令行php artisan migrate,如下图所示:
[/erphpdown]
4、最后运行你的PHP安装向导,即可完成安装!
评论前必须登录!
立即登录 注册