Read local mysql with Arduino

Hi to all, I'm developing an authentication system that receives inputs from a RFID reader and, if the code is correct, it opens a door.

The problem is that the code is stored in a MySQL database (which is frequently updated) and I can't assume to always have internet connection to send and receive requests from a remote server (with PHP/MySQL and JSON).

The best solution would be to have a local MySQL so Arduino UNO can always access it to authenticate the users in a faster and safer way and periodically receive updates from the remote server when internet is available.

The problem is: is there any way to make Arduino read the local MySQL?

I would like to avoid to install a MySQL Server on a computer and make Arduino communicate with the computer by a serial cable because in this way the computer would be very expensive.

Are there any other solutions?

How many RFID do you have in mind with your database? For authentication of a few IDs a DB is overkill, instead the IDs can be stored in RAM, flash or EEPROM and searched sequentially or by hash code. An Arduino with embedded TCP/IP protocol has much RAM available, much more than an Uno has.

Communication with the authentication server can be boiled down to messages of the kind "added/removed ID", which are requested by the Arduino whenever a connection is established. If required the Arduino also can send messages when the door has been opened by which ID, for further processing by the server.

The MySQL database has about 16.000 IDs and the updates are made on the remote server.

So, you are suggesting to load into memory the records like a structure "id, true" or "id, false" to avoid to use the local MySQL server?

This surely would be a very fast solution, but what happen if Arduino is turned off?

I was thinking about the EEPROM solution, but the problem is that Arduino needs to store the timestamp for each access and create a new record in the database, so I think I cannot just store the value in the memory since I have to write information to the database, too.

This sounds like a job for a Raspberry Pi. Just install Ubuntu Server on it, apt install mysql-server, and use a Python script for the RFID reader.

Make sure to disallow remote access to the DBMS, enable the firewall, and only allow SSH logins using authorized keys.

Pieter