SQL Access denied for user

Discussion in 'Plugin Development' started by niels1189, Jul 20, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    niels1189

    So I started coding java / plugins yesterday for the first time and got quite far since then.
    (I've coded multiple other languages so don't be too surprised)


    I'm coding a plugin that allows transferring money from one server to another.
    On my local PC it works fine and everything is set up & working now, however, when I upload it to hosthorde (the server host I use) it gives this error:

    Code:
    [11:16:53] [Server thread/INFO]: [MoneyTransfer] Enabling MoneyTransfer v1.2
    [11:16:53] [Server thread/INFO]: [MoneyTransfer] Server Money Transfer Plugin Version 1.2 Enabled
    [11:16:53] [Server thread/WARN]: java.sql.SQLException: Access denied for user 'user'@'host' (using password: YES)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:931)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4031)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1296)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    [11:16:53] [Server thread/WARN]:at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [11:16:53] [Server thread/WARN]:at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    [11:16:53] [Server thread/WARN]:at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    [11:16:53] [Server thread/WARN]:at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
    [11:16:53] [Server thread/WARN]:at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
    [11:16:53] [Server thread/WARN]:at java.sql.DriverManager.getConnection(DriverManager.java:571)
    [11:16:53] [Server thread/WARN]:at java.sql.DriverManager.getConnection(DriverManager.java:215)
    [11:16:53] [Server thread/WARN]:at io.github.niels1189.moneytransfer.MySQL.openConnection(MySQL.java:62)
    [11:16:53] [Server thread/WARN]:at io.github.niels1189.moneytransfer.moneytransfer.onEnable(moneytransfer.java:50)
    [11:16:53] [Server thread/WARN]:at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316)
    [11:16:53] [Server thread/WARN]:at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:329)
    [11:16:53] [Server thread/WARN]:at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)
    [11:16:53] [Server thread/WARN]:at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476)
    [11:16:53] [Server thread/WARN]:at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394)
    [11:16:53] [Server thread/WARN]:at net.minecraft.server.v1_7_R4.MinecraftServer.n(MinecraftServer.java:360)
    [11:16:53] [Server thread/WARN]:at net.minecraft.server.v1_7_R4.MinecraftServer.g(MinecraftServer.java:334)
    [11:16:53] [Server thread/WARN]:at net.minecraft.server.v1_7_R4.MinecraftServer.a(MinecraftServer.java:290)
    [11:16:53] [Server thread/WARN]:at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:210)
    [11:16:53] [Server thread/WARN]:at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458)
    [11:16:53] [Server thread/WARN]:at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628)
    since I didn't change anything, I'm at a loss. I have no clue what went wrong.
    I added the host in question (sXX.hosthorde.com) and the actual IP of the server to my remote SQL in cPanel. so I really don't know what else I can do.

    NOTE: user & host inside the error log are the actual IP and Username (THAT WORK on my local PC)
     
  2. Offline

    xmarinusx

    niels1189
    Every database has it's own usernames and passwords. So if you change your database you'll have to use that database's login information.

    The error you got means you're using the wrong login information for that database, by the way.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  3. Offline

    niels1189

    Ye, I know that, however. Explain to me why it WAS working on my local PC.

    Same config
    Same Plugin

    Local PC -> SQL Server -> Local PC
    Hosted Server x> SQL Server
     
  4. Offline

    xmarinusx

    niels1189
    If you used the same SQL Server, what do you use as host in both cases?
    Is the SQL server running on your local PC?
     
  5. Offline

    niels1189


    The SQL host is hosted on a 3rd party server together with my web host.
    It's functioning as a middleman to transfer the data.

    But I really don't know why this occurred. Perhaps it takes time to do the change (add hosts to remote SQL)
     
  6. Offline

    xmarinusx

    In the stack trace i can see your hostname is litteraly 'host', this should be the IP address of the MySQL server. I can't see how that has worked before though.
     
  7. Offline

    niels1189

    And I clearly stated this:

    NOTE: user & host inside the error log are the actual IP and Username (THAT WORK on my local PC)


    [​IMG]
    The above image is made after executing /transfer, and /transfer creepingcraft 10
    the image below is made from executing the same commands on the other server.
    [​IMG]

    command gives nullpointerexception because it can't connect to the database (since the connection couldn't be made at the beginning of the plugin)
     
  8. Offline

    xmarinusx

    niels1189
    Are the server and the MySQL server the same (same IP) if so, use localhost instead of its external IP.
     
  9. Offline

    niels1189


    There are 3 different servers involved in this.

    My local PC called X
    the SQL server & Web host Server called Y
    one of my MC servers called Z


    X, Y and Z do not share the same IP.

    X can connect to Y.
    X can't connect to Z.

    X and Z use the same config and plugin / code.
    X and Z are both added to Remote Database Access Hosts located on Y
    You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site.

    I've added both a domain and IP to the list.
     
  10. Offline

    xmarinusx

    niels1189
    Alright, so host shouldn't be the issue. You only get this error if you're using an incorrect password, so for some reason something must go wrong with getting the password. Please double check the password is correctly defined in (I assume) the config.
     
  11. Offline

    niels1189

    I will, but the configs are the same... At least, I copied them so they should be exactly the same
     
  12. Offline

    xmarinusx

    Was the server running when you copied them?
     
  13. Offline

    niels1189

    no, I restarted the server a few times after that so that shouldn't be the case, I'll take a look at the config now.

    I own multiple servers, so I installed the plugin on my other server and it works fine there.

    Going to try to fix the config and see if that helps

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  14. Offline

    xize

  15. Offline

    niels1189

    I think my hosting company is blocking the survival server IP, since my other server WORKS FINE.
    I created a ticket and hope it's resolved soon.
     
Thread Status:
Not open for further replies.

Share This Page