Laravel连接MySQL 8.0.11 遇到的一些坑

9 篇文章 0 订阅

1. Authentication Type

相信很多朋友在mysql升级8.0.11后发现数据库连接出现了问题
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

原因在于:
用户的 Authentication type 默认为 caching_sha2_password,导致数据库连接错误,抛出如下异常:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

解决方式:
修改密码认证方式
ALTER USER 'YOURUSERNAME'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOURPASSWORD';

2、删除了 NO_AUTO_CREATE_USER 模式

在 5.7.*的日志中提到已废除该模式,在8.0.11中删除了,迁移时会抛出如下异常:
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

解决方案:将 config/database.php 配置文件中mysql 的 strict 的值改为false即可!

转载来自:https://laravel-china.org/articles/10736/some-craters-in-mysql-8011

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值