I'm trying to connect my Discord bot to my server's MySQL database, but everytime I try to run the bot I get the following error:
let conn = mysql.createConnection({
insecureAuth : true,
host : config.mysql.host,
user : config.mysql.user,
password : config.mysql.password,
database : config.mysql.database
});
config.json:
{
"token":"bottoken",
"prefix":"m!",
"mysql": {
"host":"localhost",
"user":"root",
"password":"apassword!",
"database":"aphi"
}
}
We could add more auth methods, of course. What auth method is your server using?
Where can I see which auth method my server uses ? (Sorry, I'm not that smart when it comes to MySQL & servers)
No problem. I'm not at a computer right now, but I think it is one of the columns in the mysql.user system table row for the user you are trying to authenticate as.
It says my auth method is unix_socket

duplicate of #1507
well, kind of, need to confirm if auth_socket in mysql is same as unix_socket in mariadb. I think both rely on SO_PEERCRED
just run that mySQL query command in workbench or other mySQL client :
'root' should be your 'username' or 'root' and where 'password' your 'password'
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
is there a solution for this ? other than ALTERing USER ?
This issue is specific to the original report issue, which is to support the unit_socket auth plugin (https://github.com/mysqljs/mysql/issues/2001#issuecomment-383004539). Please create a new issue if your issue is not related to the unix_socket plugin.
Most helpful comment
just run that mySQL query command in workbench or other mySQL client :
'root' should be your 'username' or 'root' and where 'password' your 'password'
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'