The best and safest thing to do, is to void the sales transactions. You do that in Setup tab, Void transactions. First look in the inquiries to pick up the numbers first. Remember to void both sales invoice, delivery notes and sales orders. If there are GL postings and Inventory movements they will automatically be voided as well.
There are so many links between the tables that is is almost impossible to remember them all by doing this in phpMyAdmin.
BTW, if you try to void a sales order, that is also a template, it will not be voided, but this has no influence over the critical postings.