关于 docker-compose 构建 MySQL 8.0 artisan migrate 失败问题

问题概述

首先服务已经跑起来 容器各个也可以沟通 但在我进入php容器内部执行php artisan migrate 时会 产生 SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = LikeMiniGroup and table_name = migrations and table_type = 'BASE TABLE')

关于docker-compose 构建mysql 8.0 artisan migrate 失败问题

网上也查找了半天的解决办法 全部是让你在my.cnf中添加 default_authentication_plugin=mysql_native_password 之后重启服务,但是此项答案并不能解决我的问题,遂想请求各位大佬如何在不降级的情况下解决此问题 多谢

以下为本人docker-compose.yml 文件以及Dockerfile文件

关于docker-compose 构建mysql 8.0 artisan migrate 失败问题

关于docker-compose 构建mysql 8.0 artisan migrate 失败问题

关于docker-compose 构建mysql 8.0 artisan migrate 失败问题

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
CrazyLickingDog
最佳答案

以自我斧正 应该是远程链接的权限问题

  • docker exec -it mysql /bin/bash 进入mysql 容器
  • mysql -u root -p 登陆进入mysql
  • use mysql 选择musql数据库
  • grant all on *.* to 'root'@'%'; 开启root远程访问权限
  • alter user 'root'@'localhost' identified by '123456' password expire never; 更新密码
  • alter user 'root'@'%' identified with mysql_native_password by '123456'; 刷新权限
  • flush privileges; 立即生效

同时我也吧my.cnf中添加default_authentication_plugin=mysql_native_password
不知道二者是哪个起作用了 还是互相配合起作用了

4年前 评论
讨论数量: 4
CrazyLickingDog

file

file

4年前 评论
CrazyLickingDog

另将env文件配置贴上

file 如有错误 请大力鞭挞我

4年前 评论
CrazyLickingDog

以自我斧正 应该是远程链接的权限问题

  • docker exec -it mysql /bin/bash 进入mysql 容器
  • mysql -u root -p 登陆进入mysql
  • use mysql 选择musql数据库
  • grant all on *.* to 'root'@'%'; 开启root远程访问权限
  • alter user 'root'@'localhost' identified by '123456' password expire never; 更新密码
  • alter user 'root'@'%' identified with mysql_native_password by '123456'; 刷新权限
  • flush privileges; 立即生效

同时我也吧my.cnf中添加default_authentication_plugin=mysql_native_password
不知道二者是哪个起作用了 还是互相配合起作用了

4年前 评论

请教下 生产环境可以用docker-compose,然后laradock可以用于生产吗

4年前 评论
yzbfeng (作者) 4年前
CrazyLickingDog (楼主) 4年前
CrazyLickingDog (楼主) 4年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!