【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 
})
相关推荐
工业一体机老司机2 分钟前
rsync+inotify 收集车间工位机日志的完整配置
服务器·数据库·postgresql
西柚小萌新10 分钟前
【人工智能:LangGraph】--3.控制流(Edge)
java·服务器·数据库
鲁邦通物联网43 分钟前
DP动力定位系统网关替换实践:通信报文、接口迁移与测试基线设计
网络·数据库·海事网关·海事网络安全·海事网络安全网关·智慧航运·船舶远程监控
oradh1 小时前
Oracle数据块内部研究(四)
数据库·oracle
EatFan1 小时前
MySQL 与 Redis 双写一致性实战:从 Cache-Aside 到延迟双删,再到 Binlog 兜底
数据库·redis·mysql
IvorySQL2 小时前
PostgreSQL 日报|布尔列 NOT 选择率估算偏高(12 月 4 日)
数据库·postgresql
老一岁2 小时前
Redis事务_锁_持久化_主从哨兵
linux·数据库·redis
PaperData3 小时前
1970-2025年省级二氧化碳排放量面板数据
数据库
RestCloud4 小时前
ETLCloud中不同表名之间的数据库数据同步
数据库·etl·数据处理·etlcloud·数据传输·数据集成平台
少陽君5 小时前
如何在 PVE 中下载并导入 Ubuntu 24.04 Server 云镜像
linux·数据库·ubuntu