【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 
})
相关推荐
风哥2号9 分钟前
PostgreSQL数据库恢复工具FGPDU(FGEDU PostgreSQL DUL)
数据库·postgresql
智购科技智能售货柜12 分钟前
2026自动售货机峰值交易流量应对方案:从消息削峰到弹性扩容的工程实践~YH
数据库·人工智能·单片机·嵌入式硬件·yolo
JavaPub-rodert24 分钟前
Ontop 详解:不搬数据库,也能把 MySQL / PostgreSQL 变成知识图谱
数据库·mysql·postgresql
xiaoxiang96091 小时前
Git 分支同步实战:`merge -X theirs` 与完全合并方案
数据库·git·elasticsearch
GoppViper1 小时前
用户测试如何提升SEO转化率?四种实操方法与案例解析
数据库·经验分享
先吃饱再说1 小时前
后端开发绕不开的 SQL:从建表、查询到索引优化,一篇讲透
数据库·后端·sql
敲代码的小小酥2 小时前
InfluxDB时序数据库(续)
数据库·时序数据库
智购科技自动贩卖机2 小时前
自动售货机嵌入式系统Go语言开发实践:从资源受限设备到RTOS协程调度的工程化之路
大数据·linux·数据库·人工智能·yolo·架构·golang
SelectDB2 小时前
2026 年 Apache Doris 和 StarRocks 怎么选?一篇更接近真实选型的对比
大数据·数据库·数据分析
祢真伟大2 小时前
DM8 归档日志挖掘导致 TEMP 表空间不释放的问题排查
数据库