The 'in place' upgrade to Ubuntu is really outside the scope of these forums, but if one googles one might find 'differences in opinions/experiences'.
Make sure you have a full site backup of the moodle (code + sql dump + moodledata) archived OFF the server in case your 'in place' upgrade has serious issues!
The DB being fully compliant DB wise can be accomplished via cli only php scripts in admin/cli/
mysql_collation.php, mysql_compressed_rows.php, mysql_engine.php
They all have 'help' if issued with no parameters.
I no long have a 3.5.x, but did convert the db for moodles that have been marched/upgraded to be compliant for destination version at that time ... a 3.9.highest.
In your current setup, go to Site Admin, Server, Environment - update component. Screens there will have what you need and when you need it when it comes to DB compliance.
Also see:
https://docs.moodle.org/310/en/MySQL_full_unicode_support
There are some settings that are best set/can only be set in config file for the DB server.
'SoS', Ken