【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 
})
相关推荐
L·S·P1 小时前
25MB 管理 100+ 种数据库:开源轻量客户端 DBX 介绍与上手
数据库·mysql·开源·database·dbx
笃行3503 小时前
KingbaseES KSQL Developer 的连接管理、数据处理与对象管理
数据库
ha_lydms4 小时前
MaxCompute中加密与解密函数
大数据·数据库·数据仓库·hadoop·dataworks·maxcompute·odps
Shadow(⊙o⊙)4 小时前
MySQL内置函数
数据库·mysql
笃行3504 小时前
金仓 KingbaseES PL/SQL 开发全攻略:异常处理、数据类型、调试优化与过程语句
数据库
夜雪一千4 小时前
MySQL 常用 DEFAULT 默认值一览表
mysql
快乐的木子李5 小时前
mysql-26.7.0-linux26.7.0下载安装
数据库·mysql
excel6 小时前
prisma 如何处理数据库竞态
前端·数据库·后端
知行产研7 小时前
易控智驾:毛利率跃升17.2个百分点,矿山无人驾驶从“规模换增长“迈入“盈利拐点“
数据库·mysql
千里码aicood7 小时前
基于CART算法的图书分类系统设计与实现
数据库·算法·分类