How to keep mysql db as is through sysupgrade

I have a MySQL DB where I store some data. I want to run update the Firmware using sysupgrade via a bash script using the sysupgrade -n command so that the config files are rewritten. What I want is that the MySQL DB is preserved. How can achieve this goal

It has barely anything to do with OpenWrt:

You can add MySQL's files to the list of files that sysupgrade will preserve, at /etc/sysupgrade.conf. But I would also consider backing up those files outside the device, and then do a recover after the upgrade.

There's a chance to lose database consistency.
You must ensure that database is stopped before starting sysupgrade.