IgorKowalczyk / majo.exe

🚀 Discord bot for almost everything - Memes, Image editing, Giveaway, Moderation, Anime and even more! With over 150 slash commands!
https://majoexe.xyz
MIT License
263 stars 128 forks source link

MySQL - ER_CON_COUNT_ERROR: Too many connections #533

Closed HexLol closed 11 months ago

HexLol commented 1 year ago
    at Handshake.Sequence._packetToError (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    --------------------
    at Protocol._enqueue (/home/container/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/home/container/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at PoolConnection.connect (/home/container/node_modules/mysql/lib/Connection.js:116:18)
    at Pool.getConnection (/home/container/node_modules/mysql/lib/Pool.js:48:16)
    at Pool.query (/home/container/node_modules/mysql/lib/Pool.js:202:8)
    at /home/container/utilities/giveaways/giveaways.js:8:21
    at new Promise (<anonymous>)
    at Giveaways.getAllGiveaways (/home/container/utilities/giveaways/giveaways.js:7:11)
    at Giveaways._init (/home/container/node_modules/discord-giveaways/src/Manager.js:665:39)
    at new GiveawaysManager (/home/container/node_modules/discord-giveaways/src/Manager.js:59:24) {
  code: 'ER_CON_COUNT_ERROR',
  errno: 1040,
  sqlMessage: 'Too many connections',
  sqlState: undefined,
  fatal: true
}
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^
Error: ER_CON_COUNT_ERROR: Too many connections
    at Handshake.Sequence._packetToError (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    --------------------
    at Protocol._enqueue (/home/container/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/home/container/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at PoolConnection.connect (/home/container/node_modules/mysql/lib/Connection.js:116:18)
    at Pool.getConnection (/home/container/node_modules/mysql/lib/Pool.js:48:16)
    at Pool.query (/home/container/node_modules/mysql/lib/Pool.js:202:8)
    at /home/container/utilities/giveaways/giveaways.js:8:21
    at new Promise (<anonymous>)
    at Giveaways.getAllGiveaways (/home/container/utilities/giveaways/giveaways.js:7:11)
    at Giveaways._init (/home/container/node_modules/discord-giveaways/src/Manager.js:665:39)
    at new GiveawaysManager (/home/container/node_modules/discord-giveaways/src/Manager.js:59:24) {
  code: 'ER_CON_COUNT_ERROR',
  errno: 1040,
  sqlMessage: 'Too many connections',
  sqlState: undefined,
  fatal: true
}

This is the issue I am facing, I think the bot is not supposed to do this or did I missed something in the installation? Please let me know, Thanks.

IgorKowalczyk commented 1 year ago

It looks like you are trying to connect to the database too many times - change the configurations in this file: https://github.com/IgorKowalczyk/majo.exe/blob/master/config/mysql_config.js

HexLol commented 1 year ago

It looks like you are trying to connect to the database too many times - change the configurations in this file: https://github.com/IgorKowalczyk/majo.exe/blob/master/config/mysql_config.js

Error: ER_NO_SUCH_TABLE: Table 'sql7639640.giveaways' doesn't exist
    at Query.Sequence._packetToError (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    --------------------
    at Pool.query (/home/container/node_modules/mysql/lib/Pool.js:199:23)
    at /home/container/utilities/giveaways/giveaways.js:8:21
    at new Promise (<anonymous>)
    at Giveaways.getAllGiveaways (/home/container/utilities/giveaways/giveaways.js:7:11)
    at Giveaways._init (/home/container/node_modules/discord-giveaways/src/Manager.js:665:39)
    at new GiveawaysManager (/home/container/node_modules/discord-giveaways/src/Manager.js:59:24)
    at new Giveaways (/home/container/utilities/giveaways/giveaways.js:5:20)
    at module.exports (/home/container/utilities/giveaways/giveaways.js:56:18)
    at module.exports (/home/container/utilities/client/util.js:17:61)
    at module.exports (/home/container/bot/index.js:2:37) {
  code: 'ER_NO_SUCH_TABLE',
  errno: 1146,
  sqlMessage: "Table 'sql7639640.giveaways' doesn't exist",
  sqlState: '42S02',
  index: 0,
  sql: 'SELECT `data` FROM `giveaways`'
}
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^
Error: ER_NO_SUCH_TABLE: Table 'sql7639640.giveaways' doesn't exist
    at Query.Sequence._packetToError (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    --------------------
    at Pool.query (/home/container/node_modules/mysql/lib/Pool.js:199:23)
    at /home/container/utilities/giveaways/giveaways.js:8:21
    at new Promise (<anonymous>)
    at Giveaways.getAllGiveaways (/home/container/utilities/giveaways/giveaways.js:7:11)
    at Giveaways._init (/home/container/node_modules/discord-giveaways/src/Manager.js:665:39)
    at new GiveawaysManager (/home/container/node_modules/discord-giveaways/src/Manager.js:59:24)
    at new Giveaways (/home/container/utilities/giveaways/giveaways.js:5:20)
    at module.exports (/home/container/utilities/giveaways/giveaways.js:56:18)
    at module.exports (/home/container/utilities/client/util.js:17:61)
    at module.exports (/home/container/bot/index.js:2:37) {
  code: 'ER_NO_SUCH_TABLE',
  errno: 1146,
  sqlMessage: "Table 'sql7639640.giveaways' doesn't exist",
  sqlState: '42S02',
  index: 0,
  sql: 'SELECT `data` FROM `giveaways`'
}

Also recieving this error, I suppose the bot is supposed to make it's own tables?

IgorKowalczyk commented 1 year ago

Yes, it should create its own tables on startup - But as you can see it doesn't, copy the SQL code you see in this file and execute it against the database

https://github.com/IgorKowalczyk/majo.exe/blob/master/utilities/mysql/database.js

HexLol commented 1 year ago

Yes, it should create its own tables on startup - But as you can see it doesn't, copy the SQL code you see in this file and execute it against the database

https://github.com/IgorKowalczyk/majo.exe/blob/master/utilities/mysql/database.js

Thanks for the quick reply, but I am going to be honest, I am not an SQL geek, can you tell me how can I execute this from phpmyadmin?

IgorKowalczyk commented 1 year ago

I assume you already have phpmyadmin installed, select your database in the side panel: image

When you select a database at the top you should have a SQL tab: image

Click on this and paste the scripts:

CREATE TABLE IF NOT EXISTS `guild_settings` ( `guild_id` BIGINT(64) NOT NULL , `anti_selfbots` INT(1), PRIMARY KEY (`guild_id`));
CREATE TABLE IF NOT EXISTS `guild_stats` ( `guild_id` BIGINT(64) NOT NULL , `joins` JSON NULL, `leaves` JSON NULL, `last_updated` DATE NOT NULL, PRIMARY KEY (`guild_id`));
CREATE TABLE IF NOT EXISTS `users` ( `user_id` varchar(32) NOT NULL , `reputation` bigint(20), `ban` INT(1), PRIMARY KEY(`user_id`))
CREATE TABLE IF NOT EXISTS `giveaways` (`id` INT(1) NOT NULL AUTO_INCREMENT, `message_id` VARCHAR(64) NOT NULL, `data` JSON NOT NULL, PRIMARY KEY (`id`));
CREATE TABLE IF NOT EXISTS `welcome` (`guildid` VARCHAR(32) NOT NULL, `channelid` VARCHAR(32) NOT NULL, UNIQUE(`guildid`));
CREATE TABLE IF NOT EXISTS `leave` (`guildid` VARCHAR(32) NOT NULL, `channelid` VARCHAR(32) NOT NULL, UNIQUE(`guildid`));
CREATE TABLE IF NOT EXISTS `logs` (`guildid` VARCHAR(32) NOT NULL, `channelid` VARCHAR(32) NOT NULL, UNIQUE(`guildid`));

Note: For everything to work correctly your Mysql version should be at least 5.7!