文章目录
- 遇到问题
- 查看用户信息
- 修改加密规则
- 成功连入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
查看用户信息
use mysql;
select user,host,plugin from user where user='root';
出现:
这里建议新建用户然后查看(root 不知道为什么修改不了)
create user 'cauchy'@'%' identified by 'root';
创建用户
cauchy
,允许任何IP
访问%
,密码root
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
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
})