Download

MySQL Connector UE4 Plugin is available for all now.

Hello.
Currently, I am working on integration of the server-side of my game (possible, will be something like MMO) with MySQL server.
I am working on my own plugin - MySQLConnectorUE4Plugin and I decided to share it publicly: GitHub - KhArtNJava/MySQLConnectorUE4Plugin: MySQL Database Connector Plugin for Unreal Engine 4 .

Any pull requests are welcome!

Enjoy! :heart:

This is super cool; but may not be safe. I think maybe a second layer of code between server and database is still safest way instead of giving your server exe direct SQL access.
Using this you will have to make sure to isolate all game code under #if WITH_SERVER directives to make sure this code will not be sitting on client’s desktop ever.
Take a look at what ppl are doing to “Black Desert” MMO these days… hacker paradise :wink:

Good idea, added to my local TODO list!

… And added to issues on GitHub To isolate all game code under #if WITH_SERVER directives to make sure this code will not be sitting in client's desktop ever · Issue #1 · KhArtNJava/MySQLConnectorUE4Plugin · GitHub !

Thanks, I’ve been using this for a while now and it works brilliantly. I use it as a content management interface into the engine where previously I was reading lines from a text file. Massive thanks Arthur.

Thank you, Dannington!

Hi Artur,

I’m trying to use your plugin but I keep getting an error on compile. I donwloaded the github, put it on my Plugins folder and I get this message on compile:
ERROR: Unable to instantiate instance of ‘MySQLConnectorUE4Plugin’ object type from compiled assembly
Unreal Build Tool creates an instance of your module’s ‘Rules’ object in order to find out about your module’s requirements. The CLR exception details may provide more information: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ArgumentNullException: Value cannot be null.

Any ideas what I’m doing wrong?

Have you changed MySQLConnectorUE4Plugin.Build.cs for using in your project?

No, what do I need to do?

EDIT: I got it, had to change *UProjectInfo.TryGetProjectForTarget * for my project name… Sorry for the silly question! haha

Hey, this really looks great! I am going to try it, this weekend. I have been (re) learning C++ so I could use the Unreal Engine for an industrial project where I read and write data from a database (could have been SQL Server or MySQL, so this is VERY useful), as I think people would really catch on to this engine if it has a robust data engine attached to it. In fact, if you help me with this codebase, and how to get it into a project, I would be GLAD to help you: 1) enhance the functionality, 2) create a commercial product (this is just for thought), 3) share all my code with all… My current industrial (Modbus TCP) to SQL Server is on github at https://github.com/petechic/ModServe8

I know most of you are only doing gaming (I’m a gamer), but there are so many ways to use the engine. Hint: I am working on a co-op game for the team that works for Snoop (yeah, him), and would be HAPPY to have more help… peace

Feel free to email at pjschieck@aol.com

I’m looking for the MySQL Server integration for a separate engineering project, and it is very important to me, as well.

An advice for anyone who intends to use this plugin: it’s fine if you use it on a dedicated server executable (for example, a MMO server) or in some kind of internal application that connects to a local or intranet database.

But never, ever, use such kind of direct connection on binaries that are distributed to the general public, game or not. You’re literally giving away the address, username and password to your database to all your customers. No amount of encryption or obfuscation will keep people from finding it: you’re guaranteed to have people accessing your database directly and doing things that range from cheating to vandalism that can culminate in serious data loss (calling DROP TABLE, if the MySQL user permissions allow it).

So, only make direct database connections from binaries that are under your control.

How to install the plugin, please.

Editor crashes when i try to create a table. Tried to do it with a query, also crash.
Version 4.14.3

Download the plugin code from Git
Create a C++ UE4 project.
Under your [ProjectName] folder create a Plugins folder
Paste the second MySQLConnectorUE4Plugin folder in to the Plugins folder you just made (the plugin downloads and extracts to MySQLConnectorUE4Plugin\MySQLConnectorUE4Plugin… , you only need the MySQLConnectorUE4Plugin… stuff).
Edit the Plugins\MySQLConnectorUE4Plugin-master\Source\MySQLConnectorUE4Plugin\MySQLConnectorUE4Plugin.Build.cs file (change the value of MyProject in the “UProjectInfo.TryGetProjectForTarget(“MyProject”, out CheckProjectFile);” line to match the name of your project and save.
Startup the project and it will tell you some code needs recompiling. Accept and cross fingers.
If all goes well then check in your project plugins that this one is enabled.
Now you can start building the blueprints to allow connection to your DB.

I kicked off the initial connection from ‘GameInstance’ kicked off with a ‘Event Init’. Copy the pics in the Wiki. Most of the items are either functions or structures you can find with the search and use.

Note I am very new to UE4 and there may be a better place to kick off the DB portion. I will let others advise if that is the case. Also note there seems to be very little error handling in the plugin. I crashed UE4 a number of times until I found out my DB account couldn’t login to the DB server. It is now working but would have been nice to error rather than just continue and crash UE4.

Please also note that exposing any DB stuff to clients in a MP game is asking for endless nights of trying to fix your DB when someone finds out. Keep all DB stuff serverside (pref a dedicated server where the code is never publicly released). If you need the client to send or read data from the DB then get the server to act as a proxy, sanitising the requests and managing the responses.

Many thanks for the plug-in !!!
This plug-in is the same stable on all versions UE4.
For which version it was designed?

P.S. when creating a table comes the collapse of the UE …

Btw, keep in mind that MySQL is NOT free.
It costs a couple thousands of dollars to use; that is because the C++ connector has 2 licenses, one is GPL free and the other is paid.
You cannot use GPL static libs on UE4, read Epic’s EULA.

Sorry to bump, but wouldn’t using a read only account on the client protect against injection? And in your server which is a private dedi you can use the login with write access but still not drop or anything malicious?

Would be cool to figure out how I can safely store player inventories to a mysql db.

I was thinking about the same thing… But you can use it for free if you are talking to it through a php script on an external webserver.

this mySQL plugin will assertion crash while packaging, how to solve this issue, i try 4.16 and 4.17 unreal version

This makes me wonder: If I were to write a c++ server application (which doesn’t use UE4’s code in any way), and write a UE4 client which connects to this server application using TCP, and the server application makes use of mysql, that would be fine as well, right?