【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 
})
相关推荐
成为大佬先秃头9 小时前
数据库连接池:Druid
数据库·mysql·druid
晓华-warm12 小时前
Warm-Flow 1.8.5 正式发布:超时自动审批、暂存功能来了!
数据库
u01368638213 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python
light blue bird13 小时前
多页签Razor组支轴业务整顿组件
数据库·.net·ai大数据·多功能图表报表·web mvc + razor
wregjru13 小时前
【mysql】2.数据表操作
数据库·mysql
手握风云-13 小时前
基于 Java 的网页聊天室(三)
服务器·前端·数据库
LcVong13 小时前
MySQL 5.2/5.7 开启Binlog日志详细步骤(附验证+查看+恢复)
数据库·mysql·adb
FL4m3Y4n13 小时前
MySQL缓存策略
数据库·mysql·缓存
wsx_iot13 小时前
TDengine学习
数据库·学习·tdengine
不吃香菜的小趴菜14 小时前
mysql数据库打包与导入
数据库·mysql