【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 小时前
及时做APP开发实战(十二)-LazyForEach懒加载优化实践
数据库·鸿蒙
龙仔7253 小时前
人大金仓KingbaseES V8 手动单库备份&恢复操作笔记
数据库·笔记·oracle·人大金仓
宠友信息5 小时前
消息序号如何保证即时通讯源码聊天记录稳定加载
java·spring boot·redis·python·mysql·uni-app
夏贰四5 小时前
数据库迁移怎样降低人力投入?数据库迁移怎么实现全量增量同步?
数据库·数据库迁移
汇智信科5 小时前
图谱、向量、关键词、SQL多路一体,FastKG垂域召回率100%拉满
网络·数据库·ai编程·汇智信科·hsim·fastclaw·汇智龙虾
笨蛋不要掉眼泪7 小时前
MySQL架构揭秘:慢查询日志详解
数据库·mysql·架构
pulinzt8 小时前
Tableau的基础使用
数据库·numpy
糖果店的幽灵8 小时前
【langgraph 从入门到精通graphApi 篇】LangGraphAPI 方式调用 - 初识与核心概念
数据库·人工智能·langgraph
TlSfoward8 小时前
TLSFOWARD TLS指纹
开发语言·数据库·爬虫·搜索引擎·https·php
️学习的小王9 小时前
MySQL 实战:从建表到索引管理的完整指南
数据库·mysql·oracle