【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 
})
相关推荐
不知疲倦的仄仄6 分钟前
MySQL/Read View快照/MVCC/串行化
java·数据库·mysql
向夏威夷 梦断明暄22 分钟前
C# 弃元模式:从语法糖到性能利器的深度解析
服务器·数据库·c#
糖果店的幽灵1 小时前
大模型测评DeepEval快速入门-RAG指标详解
数据库·人工智能·langgraph·大模型测评·deepeval
whn19772 小时前
oracle的节点2无法启动asm实例 提示PMON terminating the instance due to error 481
数据库·oracle·wpf
Mico182 小时前
MySQL 5.7.35 升级到 8.0.35 — 原地升级(主从架构方式)
mysql
AAA@峥2 小时前
Ceph 集群配置管理完整指南
运维·数据库·分布式·ceph
旺仔学长 哈哈2 小时前
基于SpringBoot的在线招聘测评系统的设计与实现----附源码35253+数据库文档
数据库·spring boot·后端·在线招聘
吴声子夜歌3 小时前
MongoDB 4.2——索引(二)
数据库·mongodb·索引
米码收割机3 小时前
【Python】Django恒达科技门户网站(源码+文档)【独一无二】
数据库·python·科技