SoKnight / PEconomy

Spigot economy plugin with unlimited currencies, vault support and more features
GNU General Public License v3.0
3 stars 5 forks source link

Plugin apparently not connecting to MySQL #1

Closed Zaikoski closed 4 years ago

Zaikoski commented 4 years ago

So, I have tried to connect to MySQL and runeed into some problem.

The plugin start initialization and never get done.

This is the config file.

database:
  # Should plugin use MySQL database as data storage?
  # Specify 'true' to use SQLite or 'false' to use MySQL
  use-sqlite: false

  # MySQL configuration
  host: 123.12.12.12
  port: 3306
  name: rh5623
  user: rh5623
  password: **********

Host IP and password omitted.

In the Console (Multicraft) this is the only message: 04.05 07:35:17 [Server] INFO [PEconomy] Loading PEconomy v2.0.2

And then, when trying to run /peco help, I get this:

04.05 07:49:52 [Server] INFO Kaxassa issued server command: /peco help
04.05 07:49:52 [Server] ERROR null
04.05 07:49:52 [Server] INFO org.bukkit.command.CommandException: Cannot execute command 'peco' in plugin PEconomy v2.0.2 - plugin is disabled.
04.05 07:49:52 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:752) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1826) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1634) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:23) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:1076) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:1069) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:1033) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:950) ~[paper-latest.jar:git-Paper-217]
04.05 07:49:52 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241]

When I switch back to use-sqlite: true it runs properly.

By reference, I have two other plugins connected to MySQL (CoreProtect and nLogin).

(My English is a work in progress, also, first time reporting something in GitHub. Sorry for any mistakes).

SoKnight commented 4 years ago

It's can't send only 04.05 07:35:17 [Server] INFO [PEconomy] Loading PEconomy v2.0.2. Your console should have more logs from PEconomy.. May be error logging is disabled?

PEconomy must send error message and stack trace if connection to database has been failed.

Zaikoski commented 4 years ago

I may not have looked at the log correctly.

Here is what I have found on logs file after running it again with use-sqlite: false.

[14:10:23] [Server thread/INFO]: [PEconomy] Enabling PEconomy v2.0.2
[14:10:23] [Server thread/INFO]: [PEconomy] Currency 'Moedas' will be used for Vault economy.
[14:10:23] [Server thread/INFO]: [PEconomy] Loaded 2 currencies.
[14:10:23] [Server thread/ERROR]: [PEconomy] Failed to initialize database: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)
[14:10:23] [Server thread/WARN]: java.sql.SQLException: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:864)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4384)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1269)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2189)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
[14:10:23] [Server thread/WARN]:    at sun.reflect.GeneratedConstructorAccessor37.newInstance(Unknown Source)
[14:10:23] [Server thread/WARN]:    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[14:10:23] [Server thread/WARN]:    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)
[14:10:23] [Server thread/WARN]:    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)
[14:10:23] [Server thread/WARN]:    at java.sql.DriverManager.getConnection(DriverManager.java:664)
[14:10:23] [Server thread/WARN]:    at java.sql.DriverManager.getConnection(DriverManager.java:208)
[14:10:23] [Server thread/WARN]:    at com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:266)
[14:10:23] [Server thread/WARN]:    at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:187)
[14:10:23] [Server thread/WARN]:    at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:397)
[14:10:23] [Server thread/WARN]:    at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:383)
[14:10:23] [Server thread/WARN]:    at com.j256.ormlite.table.TableUtils.createTableIfNotExists(TableUtils.java:75)
[14:10:23] [Server thread/WARN]:    at ru.soknight.peconomy.database.Database.<init>(Database.java:43)
[14:10:23] [Server thread/WARN]:    at ru.soknight.peconomy.PEconomy.onEnable(PEconomy.java:44)
[14:10:23] [Server thread/WARN]:    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263)
[14:10:23] [Server thread/WARN]:    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:364)
[14:10:23] [Server thread/WARN]:    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483)
[14:10:23] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:470)
[14:10:23] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:384)
[14:10:23] [Server thread/WARN]:    at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:488)
[14:10:23] [Server thread/WARN]:    at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:298)
[14:10:23] [Server thread/WARN]:    at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:895)
[14:10:23] [Server thread/WARN]:    at java.lang.Thread.run(Thread.java:748)
[14:10:23] [Server thread/INFO]: [PEconomy] Disabling PEconomy v2.0.2

I'm not used to MySQL but the IP that shows on log, user 'rh5623'@'170.81.41.111' it's not the one I used in the config.

Also, I checked again the Host IP, name, user name and password. They match with the ones that I use on others plugins.

SoKnight commented 4 years ago

Oh.. May be you try to use fake IP? The error message will be similar or not?

Zaikoski commented 4 years ago

Not similar. Changed IP to a fake IP and got this:

04.05 16:10:33 [Server] INFO [PEconomy] Currency 'Moedas' will be used for Vault economy.
04.05 16:10:33 [Server] INFO [PEconomy] Loaded 2 currencies.
04.05 16:11:03 [Server] ERROR [PEconomy] Failed to initialize database: Communications link failure
04.05 16:11:03 [Server] INFO The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
04.05 16:11:03 [Server] WARN com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
04.05 16:11:03 [Server] WARN The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
04.05 16:11:03 [Server] WARN at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
04.05 16:11:03 [Server] WARN at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
04.05 16:11:03 [Server] WARN at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
04.05 16:11:03 [Server] WARN at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:335)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2187)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
04.05 16:11:03 [Server] WARN at sun.reflect.GeneratedConstructorAccessor37.newInstance(Unknown Source)
04.05 16:11:03 [Server] WARN at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
04.05 16:11:03 [Server] WARN at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)
04.05 16:11:03 [Server] WARN at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)
04.05 16:11:03 [Server] WARN at java.sql.DriverManager.getConnection(DriverManager.java:664)
04.05 16:11:03 [Server] WARN at java.sql.DriverManager.getConnection(DriverManager.java:208)
04.05 16:11:03 [Server] WARN at com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:266)
04.05 16:11:03 [Server] WARN at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:187)
04.05 16:11:03 [Server] WARN at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:397)
04.05 16:11:03 [Server] WARN at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:383)
04.05 16:11:05 [Multicraft] Skipped 34 lines due to rate limit (30/s)
SoKnight commented 4 years ago

Try to set ' around IP address and change the name of database (database.name) to another string (not similar with user).

SoKnight commented 4 years ago

Probably, this problem is on your side, sorry. I'm looked at my database connector code, but I didn't find anything.

voidpointer0x00 commented 4 years ago

[14:10:23] [Server thread/ERROR]: [PEconomy] Failed to initialize database: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES) [14:10:23] [Server thread/WARN]: java.sql.SQLException: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)

To sum up, you have an invalid database connection URI. Try to connect It manually using your terminal mysql -u USERNAME -h HOST DATABASE -p or any other service. Then, if it's correct, insert final connection credentials into plugin configuration and retry.

Zaikoski commented 4 years ago

So, after setting ' around IP and changed the database name to peconomy, this is the log:

04.05 16:23:24 [Server] INFO [PEconomy] Enabling PEconomy v2.0.2
04.05 16:23:24 [Server] INFO [PEconomy] Currency 'Moedas' will be used for Vault economy.
04.05 16:23:24 [Server] INFO [PEconomy] Loaded 2 currencies.
04.05 16:23:24 [Server] ERROR [PEconomy] Failed to initialize database: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)
04.05 16:23:24 [Server] WARN java.sql.SQLException: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)
04.05 16:23:24 [Server] WARN at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
04.05 16:23:24 [Server] WARN at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
04.05 16:23:24 [Server] WARN at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
04.05 16:23:25 [Multicraft] Skipped 38 lines due to rate limit (30/s)

The strangest (oddest?) part to me is that nLogin and CoreProtect are connected and working with MySQL.

To sum up, you have an invalid database connection URI. Try to connect It manually using your terminal mysql -u USERNAME -h HOST DATABASE -p or any other service. Then, if it's correct, insert final connection credentials into plugin configuration and retry.

I'll try to figure out how to do this, as I have no clues. As soon I get it done, or not, I'll be back here.

Zaikoski commented 4 years ago

So! I discovered how to connect to the MySQL, and made a SELECT just to test it.

It went all good. Still not able to connect from PEconomy thought.

image

Zaikoski commented 4 years ago

I Would like to address one more thing. I finished installing another plugin that uses MySQL (Statz). And it's working properly as far as I can see.

So, maybe it's a problem with permissions from my side, because I don't have full permissions in MySQL. But, probably, there's a workaround. Besides that, I experienced other Servers Host Providers that are almost the same, not allowing full control over the Databases.

SoKnight commented 4 years ago

You connected to 170.81.41.76, not a 111... May be you should set this correct address into PEconomy config file?

voidpointer0x00 commented 4 years ago

I've just tried to install the plugin with MySQL (MariaDB locally) by myself and it works perfectly, so I suppose these are troubles on your side. Recheck your MySQL credentials and user permissions.

I have a local MariaDB service with user 'test'@'localhost' with no password and full access to the 'test' database, so my configuration section looks like this:

database:
  use-sqlite: false
  host: localhost
  port: 3306
  name: test
  user: test
  password: ''
  file: database.db
Zaikoski commented 4 years ago

You connected to 170.81.41.76, not a 111... May be you should set this correct address into PEconomy config file?

Actually, I've set the PEconomy config file since from the begging to connect to 170.81.41.76

database:
  # Should plugin use MySQL database as data storage?
  # Specify 'true' to use SQLite or 'false' to use MySQL
  use-sqlite: false

  # MySQL configuration
  host: 170.81.41.76
  port: 3306
  name: rh5623
  user: rh5623
  password: **********

So I went all the way from the beginning, fresh started the server. The plugin seems to work fine until switched to MySQL. Still unable to connect.

[PEconomy] Enabling PEconomy v2.0.2
05.05 16:49:36 [Server] INFO [PEconomy] Loaded 2 currencies.
05.05 16:49:36 [Server] ERROR [PEconomy] Failed to initialize database: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)
05.05 16:49:36 [Server] WARN java.sql.SQLException: Access denied for user 'rh5623'@'170.81.41.111' (using password: YES)

I also started a ticket with my server provider, they're completely useless. Good to know that though. I'm making all the configs from the server and problably will change my provider as for production.

Just to add, I've tried to connect direclty througth MySQL WorkBench 8.0 and was unable also. The only way was using MySQL Query Browser due to a bad handshake error. Solution for direct connect..

I'll stick to using SQLite by now, until trying again in another host.

voidpointer0x00 commented 4 years ago

By the way, is your database named 'rh5623' in MySQL? Just I've noticed that the database.name yaml path is a bit misleading.

At this point, you can contact me on SpigotMC (I have the same nickname on there) and I'll create a database for you on my German host (at least for this month) (totally free :D)

Zaikoski commented 4 years ago

By the way, is your database named 'rh5623' in MySQL?

Yes, it is! image

This Host "REISHOST" is a popular provider here in Brazil. They use the same "key" of the user account for almost anything they need. So my account is rh5623. The database name is the same, the user name is the same. Kinda weird.

I have only privileges creating tables inside this database. It's messy all the tables mixed.

At this point, you can contact me on SpigotMC (I have the same nickname on there) and I'll create a database for you on my German host (at least for this month) (totally free :D)

OMG! This is really kind! Thank you! I'll be in touch if needed. Thanks again!

SoKnight commented 4 years ago

Okay. I think that I should to close this issue. If the problem persists, continue in the new issue. Good luck!