【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 
})
相关推荐
FungLeo2 小时前
FengCMS · PHP+MySQL 升级实录 · 输出转义的度:面包屑双重编码、默认转义与 cms_html()信任声明
mysql·html·php·fengcms·输出转义
Decay__3 小时前
PostgreSQL 用户权限与安全 —— 角色体系、GRANT 授权、pg_hba.conf 认证、行级安全与审计
运维·数据库·sql·postgresql
Escalating_xu3 小时前
【MySQL】索引原理(上):从数据页到 B+ 树,弄懂聚簇索引、回表与覆盖索引
数据库·mysql
FungLeo4 小时前
FengCMS ·PHP+MySQL升级实录 · 富文本清洗配置实战:白名单、URI scheme、禁 iframe/id、实例缓存
mysql·缓存·php·xss·fengcms
DataY轻量数据平台4 小时前
MongoDB 怎么做 CDC?不用 Debezium,Change Streams 就是它的“binlog”
数据库·mongodb
djjjx.5 小时前
Mysql数据库基础篇(十):从磁盘 IO 到 B+ 树:图解 MySQL 索引的底层演进、Page 结构、目录机制与 IO 优化原理
数据库·mysql
En^_^Joy5 小时前
LangChain消息系统全解析:从基础到实战(四)
数据库·microsoft·langchain
CoderYanger6 小时前
Java EE 进阶:11. SpringBoot 统一功能处理(第三弹):统一数据返回格式+统一异常处理
java·数据库·spring boot·后端·spring·java-ee·mybatis
飞奔的瓜牛6 小时前
运维工程师 Redis 日常巡检清单与实战注意事项
运维·数据库·redis
龙腾AI白云6 小时前
视觉运动控制与灵巧抓取:具身智能手眼协调的学习
大数据·数据库·人工智能·机器学习·pygame