MySQL server

Hello, I want to use a database on a server outside the PLCnext. I thought that the open-source MySQL server was a nice option. I’ve set up a local server on my host-device. Is there something like the SQLlite set up (https://www.plcnext-community.net/index.php?option=com_content&view;=article&id;=368:how-to-use-sqlite-in-a-plcnext-c-project&catid;=78&Itemid;=366⟨=en) for a SQL server? I think the best way to do this is in C++? There are some tutorials for that online for the C++/MySQL connector, but I’ve got some struggles with combining it with the PLCnext. Or should I use something else then MySQL? I need save it on some kind of server, and my mentor says SQL is the best language to use. So what are your ideas? Arne

Hey Arne,

Maybe I’m gonna be able to give you some hints, but be aware that I’m no expert with using DBs in C++.

You should take a note that there is one major difference between MySQL and SQLite - the first one is server based (so you send all the queries over to a machine which which you have to authorize that runs the engine and handles all your DB files.), where the latter is server-less (have a DB file and the database is directly integrated within your application, as shown in the link provided by you). Now if you want to communicate with a remote MySQL server through code, you will need to get a MySQL Connector and integrate it into you code. Beside the dedicated C++ connector for MySQL, which you would have to first build from the source, I can see that there is some mysql-connector-odbc in the optware-ng (recommended package manager for PLCNext) repository, but my experience with MySQL is limited to using it in Visual C# only.
If you really have to use a server, but have too much trouble with setting up the MySQL connector for the C++, then maybe an option for you would be to use SQLite DB stored on a shared network drive, which would be accessible to parties concerned. Pay in mind that you have to deal with the security side on your own, since SQLite, does not come with any user management system.

Hope this gonna help you a bit.

Regards,
Michael

I can also use C#, as I am able to implement it. My mentor wants me to use a external server as he thinks that is better. So I can’t use SQlite. But there is a SQlite example online, so I was searching for something similair as that tutorial, but then with MySQL or another languages. Is C# the easiest way? Or should I install the optware ng lib? Arne

If you can go for C#, then I think that this will be the easiest way to get it running if you have to use MySQL. There is connector library made specifically for that (https://dev.mysql.com/downloads/connector/net/). From my past experience I found it easy to interact with a DB in this way.

Michael