【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 
})
相关推荐
Sais_Z10 分钟前
ClickHouse的学习与了解
数据库·clickhouse
代码的余温33 分钟前
MySQL性能优化:10个关键参数调整指南
数据库·mysql·性能优化
silver98861 小时前
sql链接的url中serverTimezone的作用
数据库·sql
tanxiaomi2 小时前
数据库索引视角:对比二叉树到红黑树再到B树
数据结构·数据库·b树
花花无缺2 小时前
mysql常用的基本函数
mysql
水无痕simon2 小时前
5 索引的操作
数据库·elasticsearch
柏油3 小时前
可视化 MySQL binlog 监听方案
数据库·后端·mysql
k↑3 小时前
微服务之注册中心与ShardingSphere关于分库分表的那些事
数据库·微服务·架构·shardingsphere
柏油4 小时前
MySQL 字符集 utf8 与 utf8mb4
数据库·后端·mysql