A defence ministry spokesman told BBC that Jakraphanth Thomma, a junior officer, had attacked his commanding officer before stealing a gun and ammunition from a military camp.
He then opened fire at a Buddhist temple and at a shopping centre in the city, north-east of Bangkok.
The suspect is still at large.
Local media footage appears to show the suspect getting out of a car in front of the
Terminal 21 shopping centre in the Muang district and firing shots as people flee, the BBC reported.
Authorities have been sealing off the centre as they try to track down the suspect, who is reportedly inside the building.
The suspect posted on his social media accounts during the attack, with one post on Facebook asking whether he should surrender.
He had earlier posted an image of a pistol with three sets of bullets, along with the words: "It is time to get excited."