【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 
})
相关推荐
李白客15 小时前
KES新版MySQL兼容能力再升级意味着什么?
mysql·国产数据库
ClouGence17 小时前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
飞将19 小时前
从零实现数据库(2)——HashIndex + IndexManager
数据库
Nturmoils2 天前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库
渣波2 天前
拒绝 SQL 焦虑!手把手带你用 NestJS + Prisma + DTO 写出“防弹”级后端代码
javascript·数据库·后端
Jim6003 天前
【吃透 MySQL InnoDB连载】第 1 章・解密线上数据库高频故障
mysql
GreatSQL3 天前
gt-checksum v4.0.0 新功能解读系列文章(4):SSL 加密连接——数据校验传输安全再升级
mysql
倔强的石头_3 天前
KingbaseES 新版MySQL 兼容版体验:旧版迁移 + 功能实测
数据库
倔强的石头_6 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库