跟着教程到这一步报错。
php artisan migrate
Illuminate\Database\QueryException : SQLSTATE[HY000] [1130] Host 'learn.test' is not allowed to connect to this MySQL server (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations)
at /var/www/html/learn_laravel/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 this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [1130] Host 'learn.test' is not allowed to connect to this MySQL server")
/var/www/html/learn_laravel/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:50
2 PDOException::("SQLSTATE[HY000] [1130] Host 'learn.test' is not allowed to connect to this MySQL server")
/var/www/html/learn_laravel/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46
Please use the argument -v to see more details.
这是我的数据库配置
正在回答
你好,报错原因是因为1071指定密钥太长,最大密钥长度为767字节,
解决办法:
在app/Providers/AppServiceProvider.php文件并在boot方法内设置默认字符串长度:
注:异常中明确指明最大长度是767字节,utf8mb4编码每字符使用4字节,所以 767 / 4 = 191.75,所以将string的默认长度设置为191字符即可,如果解决您的问题请采纳,祝学习愉快!
- 参与学习 人
- 解答问题 722 个
掌握开发中必备技能解锁缓存、支付,邮件和短信发送等高端接口运用,直击工作重难点,通过开发简书项目熟练掌握Laravel5的开发技术。完成以上三个阶段的学习,成为满足企业需求的开发工程师。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星