How do you treat mouth ulcers?

Gargle and avoid... Since you mouth is teeming with bacteria, and the sore is the result of a herpes reactivation to due the virus perceiving stress: 1. Reduce the bruden of bacteria near the wound by gargling with listerine or salt water 60seconds twice a day until the sores go away (the bacterial load near the sore may delay healing), and 2. Avoid sour, citrus, acidic, spicey foods which will irritate the sore.
Such a broad topic. Most commonly ulcers are not bacterial or viral in nature. Some are simply due to stress or trauma. Some are associated with a virus. Some are much more painful skin disorders which manifest in the mouth. Generally they will resolve in 7 days, with the use of warm salty water. Viral cold sores can be medicated. Most cannot.