【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 
})
相关推荐
我科绝伦(Huanhuan Zhou)1 分钟前
oracle RAC共享存储换盘操作指南
数据库·oracle
wangbing11258 分钟前
重建oracle服务
数据库·oracle
唐小码9 分钟前
MYSQL表中没有主键,怎么找到重复的数据
数据库
fengkai454514 分钟前
十一、MySQL 第 4-7 章
运维·数据库·mysql
我科绝伦(Huanhuan Zhou)21 分钟前
PostgreSQL 数据库小版本与大版本升级详解
数据库·postgresql
ao-weilai38 分钟前
MySQL数据库:索引
数据库·mysql
shaibdoio41 分钟前
瞬维AI落地经验:AI Agent工具调用准确率怎么提
数据库·人工智能·oracle
NPE~1 小时前
CMDB科普:配置管理数据库——运维相关
运维·数据库·科普·cmdb·配置管理数据库
Highcharts.js1 小时前
动态数据可视化架构:Highcharts + PHP + MySQL 从数据库到数据渲染
数据库·mysql·php·开发文档·实时数据·highcharts·图表开发
余槐i1 小时前
WAL 下写并发仍是 1:SQLite 单写者模型实测与绕开方案
数据库·python·性能优化·sqlite·wal