【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 
})
相关推荐
herinspace18 分钟前
管家婆软件年结存后快马商城操作注意事项
服务器·数据库·windows
qq_3482318538 分钟前
MySQL 与 PostgreSQL PL/pgSQL 的对比详解
数据库·mysql·postgresql
玩转数据库管理工具FOR DBLENS1 小时前
DBLens:开启数据库管理新纪元——永久免费,智能高效的国产化开发利器
数据结构·数据库·测试工具·数据库开发
芝麻馅汤圆儿1 小时前
sockperf 工具
linux·服务器·数据库
IndulgeCui1 小时前
金仓数据库征文_使用KDTS迁移mysql至金仓数据库问题处理记录分享
数据库
cui_win1 小时前
Prometheus实战教程 - mysql监控
mysql·prometheus·压测
wsx_iot1 小时前
mysql的快照读和当前读
数据库·mysql
梁萌1 小时前
MySQL分区表使用保姆级教程
数据库·mysql·优化·分区表·分区·partitions
期待のcode2 小时前
MyBatis-Plus的Wrapper核心体系
java·数据库·spring boot·后端·mybatis
透明的玻璃杯2 小时前
sqlite数据库链接池二
数据库·oracle·sqlite