【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 访问 database 中 chat 数据库的所有表 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 
})
相关推荐
富贵儿9986 分钟前
NL2SQL 实践手记 06:四个角色怎样合作——拆解一个 Multi-Agent 查询系统
数据库·sql·ai·自然语言处理·langchain
codeejun27 分钟前
每日一Go·MySQL-24、死锁排查与解决方案
开发语言·mysql·golang
Decay__2 小时前
PostgreSQL 监控体系构建 —— postgres_exporter + Prometheus + Grafana 全栈实战
运维·数据库·sql·postgresql
码农张33 小时前
MySQL 8.4.13 LTS 压缩版安装步骤 + 规范配置文件
mysql
Decay__4 小时前
PostgreSQL 告警与自动化运维 —— 告警分级收敛、Webhook、定时巡检、脚本库
运维·数据库·sql·postgresql
老纪的技术唠嗑局5 小时前
OceanBase × 知跃空间智能:从感知,到记忆,再到行为,打造具身智能数据底座
数据库
郝学胜-神的一滴5 小时前
Effective Python 条款45:巧用属性注解平滑升级类属性
运维·开发语言·数据库·python·网络协议·numpy
千寻技术帮7 小时前
基于微信小程序的零食销售系统(源码+文档+脚本)50047
数据库·mysql·微信小程序·小程序·毕业设计·springboot·课程设计
张人玉8 小时前
C#如何使用FreeSql连接数据库
数据库·c#·freesql
codeejun8 小时前
每日一Go·MySQL-25、如何解决高并发写冲突?
数据库·mysql