MYSQL ERROR

Discussion in 'Bukkit Help' started by Glass_Eater84, Jul 19, 2014.

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

    Glass_Eater84

    Hey guys/girls,
    today I have an error when trying to connect to a plugin called maxbans with mysql. Here is the error; http://pastebin.com/PE5nTvmB Also, I am using MAMP from my computer and PHP my admin, It works on my test server that I host from my house but not the one that is hosted by a compony. Also, I am using localhost to connect. Any help is much appreciated!
     
  2. Offline

    LHammonds

    Sounds like your database connection setting is incorrect.

    Even if you get connected to your database, you might still not be able to access the database depending on how you defined your user.
     
  3. Offline

    Glass_Eater84

    LHammonds thanks for the response What do you mean my connection setting is incorrect? Do you mean like type of host or...?
    Glass
     
  4. Offline

    LHammonds

    Sorry, I didn't finish with the post, I had to go. I'm guessing the host/ip part of your connection info is incorrect. If on your own PC, it was probably localhost. If on a host provider, it "might" be localhost or it might be a generalized mysql server separate from your machine. I can't tell you that info.

    But how you create your IDs can be critical based on where your MySQL server resides...but I don't think your error was related to that but it might after you fix the initial problem.

    Info on setting up an existing MySQL database to let a plugin connect to it:
    1. You must create a database.
    2. You must create a login account.
    3. You must grant permissions for that login account to that database.
    4. You update your plugin configuration to specify the MySQL database server name/ip, the database name, user ID and user password.
    5. Most plugins will create the tables and populate the data as long as you have done the prior steps.
    How you do all of these depends on the tools you use. If you have access to the server command prompt where the database is installed, you can run the mysql command-line. If you access the database using PhpMyAdmin, then you can run queries inside that. If you are running MySQL on a Windows machine and you have WorkBench installed, you can use that utility. I'm sure there are several other ways as well and depending on how you connect will decide the exact steps you take.

    Creating the database and user accounts are the super easy parts that are extremely easy to find via google.

    The step to grant permission can require a bit more knowledge of how your server is setup and can determine if you pass or fail in your connection attempt. For example, if your MySQL database is run on the same server as your minecraft server, then you can grant access for the user ID to the database as "local only" access. If your database is on a different server, you can grant access for the user ID to that database for "that server name" only...meaning the user ID is only allowed to connect from your specified minecraft server machine/IP. Another option is to grant access for that user ID to the database as "global" access meaning that ID can connect to the database from anywhere in the world...which is typically not as secure but can be handy if your machine name changes or you have multiple servers that connect to the same database and you use the same ID.

    Here are some examples of SQL syntax for setting up a database called "minecraft" with an ID of "minecraftuser" and password of "mypass123" but I STRONGLY suggest you never use this exact ID/pass combo now that the entire world knows about it.

    Example #1 - Database and Minecraft on same machine
    Code:
    CREATE DATABASE minecraft;
    CREATE USER 'minecraftuser'@'localhost' IDENTIFIED BY 'mypass123';
    GRANT ALL PRIVILEGES ON minecraft TO 'minecraftuser'@'localhost';
    FLUSH PRIVILEGES;
    
    Example #2 - Minecraft on separate machine called srv-minecraft
    Code:
    CREATE DATABASE minecraft;
    CREATE USER 'minecraftuser'@'srv-minecraft' IDENTIFIED BY 'mypass123';
    GRANT ALL PRIVILEGES ON minecraft TO 'minecraftuser'@'srv-minecraft';
    FLUSH PRIVILEGES;
    
    Example #3 - User ID able to login to database from anywhere
    Code:
    CREATE DATABASE minecraft;
    CREATE USER 'minecraftuser'@'%' IDENTIFIED BY 'mypass123';
    GRANT ALL PRIVILEGES ON minecraft TO 'minecraftuser'@'%';
    FLUSH PRIVILEGES;
    
    LHammonds
     
  5. Offline

    Glass_Eater84

    LHammonds Ok, but which would I have to use if it is being hosted elsewhere not from my computer? Which field would I put the servers ip or would I do localhost? I can show you what my database looks like if that would help.
    [​IMG]

    [​IMG]

    I am working with FlashbackBans.

    Also, when I say which field I mean this one:
    [​IMG]
    Where it says host what should I put there, if its NOT being hosted from my computer, but from a componu.
     
  6. Offline

    LHammonds

    That looks like a database on your local PC. If your Minecraft server also runs on the same PC, you would use Example #1 to create an ID that can only login from the local machine which would be very secure since another computer on your own internal network wouldn't even be able to use that ID/password to connect remotely.

    However, if you don't care as much about keeping it as secure as possible, you could go with Example #3 which would allow that ID to login from any machine in the world and it wouldn't care.

    I don't use those GUI screens. If it were me, I'd click the SQL tab and put my SQL commands in there. ;)

    LHammonds
     
  7. Offline

    Glass_Eater84

    LHammonds Ok so if it is hosted from a compony and I am doing this off my computer I can still do it correct? Would I just put the servers IP in or localhost that is where I am confused.
    Best Regards,
    Glass
     
  8. Offline

    LHammonds

    Depends on what you are saying is hosted. Is only the MySQL database at another location and your Minecraft server is running off your PC?
    No matter how you are doing it, it is possible but if the Minecraft and MySQL machines are in different physical locations, you also have to consider the firewall rules that allow communication to pass through.
    LHammonds
     
  9. Offline

    Glass_Eater84

    Yea only the sql database is off my computer. So I have to setup a firewall because it is not safe?
     
  10. Offline

    LHammonds

    The point is, most every computer has some kind of hardware router / firewall and sometimes a software firewall that blocks most traffic trying to reach it from the internet. A host provider letting you use their database would be no different. But if all they are doing is providing you access to your database, they must have given you an IP address or domain name to reach the server and then a port number which they allowed through their router/firewall to access the database. The default port for MySQL is 3306 but if they host many databases, they might have given you a different port. It is this server address and port number that you need in your plugin configuration just to be able to reach the database. The 2nd half of the equation is an ID/password which is completely under your control.

    Since the database server is remote, you can only create an ID using the example I provided of #2 or #3. #2 requires you to use your machine name/IP exactly how the database server would see you as an incoming connection. If you have a dynamically change IP address, this might not be a wise idea. So #3 option where the ID can connect from anywhere in the world might be your easiest solution (that works all the time). But since anyone could connect to your database if they know the ID/password, I'd recommend making the ID and password very difficult to hack.

    Another concern I'd have is the line of communication from your server to the database. I've never dealt with an external connection so I never had to research it but if you don't have some kind of secured / encrypted communication channel to the database, it is possible people can "sniff" your internet connection and intercept login credentials if not encrypted. Then again, what you are storing on that databases may not be worth anything to anyone and may never be the target of an attack but its something to think about.

    LHammonds
     
Thread Status:
Not open for further replies.

Share This Page