【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 
})
相关推荐
城北徐宫13 小时前
MySQL数据类型整理
数据库·mysql
数据库小学妹13 小时前
数据库容量规划:四个数与扩容触发线
运维·数据库·后端
时间的拾荒人14 小时前
Redis Cluster 集群详解:分片算法、搭建、故障处理与扩容实战
数据库·redis·算法·集群
纆兰17 小时前
MySQL的多表查询
数据库·mysql
七夜zippoe17 小时前
Nexent 模型配置:4 字段与 9 个槽位
数据库·人工智能·模型·nexent
进击的荆棘17 小时前
MySQL——表的操作
数据库·mysql
小番茄程序猿17 小时前
一条 ALTER 拖死全表:MDL 阻塞的完整时间线(8.4.11 实测)
后端·mysql
nice_lcj52019 小时前
MySQL 慢查询与 EXPLAIN:怎么定位、怎么优化
java·数据库·后端·mysql
码客-ygluu1 天前
X3 LUA 异步分布式微服务集群框架
c++·架构·lua
OceanRoy1 天前
数据库表的设计
数据库·内连接·外连接·er图·表的约束·三大范式·多表连接