Answer the question
In order to leave comments, you need to log in
Why won't mysql let the bot?
I took a VPS, somehow raised one bot on it through a stump-deck, was delighted, and decided to raise the second one. Having transferred the database and the bot itself, I ran into such a problem: I can use it through the console and the client, but on mysql2 in the bot it swears "ACCEST DENIED":
# node main
events.js:174
throw er; // Unhandled 'error' event
^
Error: Access denied for user 'root'@'localhost'
at Packet.asError (/root/bots/dc_gth/node_modules/mysql2/lib/packets/packet.js:712:17)
at ClientHandshake.execute (/root/bots/dc_gth/node_modules/mysql2/lib/commands/command.js:28:26)
at Connection.handlePacket (/root/bots/dc_gth/node_modules/mysql2/lib/connection.js:425:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/root/bots/dc_gth/node_modules/mysql2/lib/connection.js:75:12)
at PacketParser.executeStart (/root/bots/dc_gth/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/root/bots/dc_gth/node_modules/mysql2/lib/connection.js:82:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
Emitted 'error' event at:
at Connection._notifyError (/root/bots/dc_gth/node_modules/mysql2/lib/connection.js:225:12)
at ClientHandshake.Connection.handshakeCommand.on.err (/root/bots/dc_gth/node_modules/mysql2/lib/connection.js:114:14)
at ClientHandshake.emit (events.js:203:15)
at ClientHandshake.execute (/root/bots/dc_gth/node_modules/mysql2/lib/commands/command.js:33:14)
at Connection.handlePacket (/root/bots/dc_gth/node_modules/mysql2/lib/connection.js:425:32)
[... lines matching original stack trace ...]
at addChunk (_stream_readable.js:288:12)
# mysql -p -u root
Enter password: %mypass%
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.25-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
const mysql = require('mysql2');
const cfg = require('./config.json');
const connection = mysql.createConnection({
host:"localhost",
user:cfg.dbLogin,
database:"gth_db",
password:cfg.dbPass
});
Answer the question
In order to leave comments, you need to log in
Fixed by creating a new user and giving him almost all rights.
The only thing is that mysql swears at any operations, although the user has the rights to them ...
1) Create a user:
CREATE USER 'user'@'%' IDENTIFIED BY 'password';
2) Grant rights (for each necessary database separately):
GRANT ALL PRIVILEGES ON database.table TO 'user'@'%';
Error: Access denied for user 'root'@'localhost'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question