【Mysql 连接报错】

文章目录

遇到问题

socket: auth failed .../.../lualib/skynet/socketchannel.lua:482: errno:1251, msg:Client does not support authentication protocol requested by server; consider upgrading MySQL client,sqlstate:08004

查看用户信息

  1. use mysql;
  2. select user,host,plugin from user where user='root';

出现:

这里建议新建用户然后查看(root 不知道为什么修改不了)

  1. create user 'cauchy'@'%' identified by 'root';

创建用户 cauchy,允许任何 IP 访问 %,密码 root

  1. grant all privileges on chat.* to 'cauchy'@'%';

授权所有权限给任何 IP 登上的用户 cauchy 访问 databasechat 数据库的所有表 chat.*

执行:select user,host,plugin from user where user='cauchy';

mysql 8 之前的版本中加密规则是 mysql_native_password ,而在 mysql 8 之后,加密规则是 caching_sha2_password

修改加密规则

alter user 'cauchy'@'%' identified with mysql_native_password by 'root';

成功连入mysql

lua 复制代码
local ok, db = pcall(mysql.connect, {
    host = "127.0.0.1",
    port = 3306,
    database = "chat",
    user = "cauchy",
    password = "root",
    max_packet_size = 1024 * 1024, 
    charset = "utf8",
    on_connect = function() end 
})
相关推荐
极限实验室5 分钟前
INFINI Easysearch 向量搜索实战(一)
数据库·搜索引擎
枫叶丹48 分钟前
数据库上 Kubernetes 后,KES-Operator 如何简化集群运维
数据库
蓝速科技23 分钟前
数字人一体机芯片选型:RK3576 与 X86 场景化对比指南丨蓝速科技
大数据·运维·数据库·人工智能·科技
IvorySQL29 分钟前
AI 时代,PostgreSQL 正在发生什么变化?
数据库·人工智能·postgresql
隔窗听雨眠34 分钟前
分析型数据库与事务型数据库:核心差异与选型决策深度解析
数据库
RestCloud1 小时前
大数据量ETL同步优化:亿级表同步与性能调优
mysql·数据迁移·数据传输·数据同步·亿级数据传输·大数据量传输
feng_you_ying_li1 小时前
mysql基本介绍,截止到类型float的一部分介绍
mysql
高级程序源1 小时前
django校企合作实习基地管理系统82506-计算机课程设计、毕业设计
vue.js·后端·python·mysql·django·课程设计·pygame
吠品1 小时前
纯HTML+ECharts构建交互式数据看板:实现思路与踩坑记录
java·服务器·数据库
dkbnull1 小时前
数据库性能调优详解
数据库·mysql