Even though your toilet empties into a sewer, it isn't supposed to smell like one. The water in the toilet's internal S-trap effectively prevents that. If you smell sewer gases, they're probably coming from under the toilet where it connects to the waste line by means of a fitting called the toilet flange. If the flange is corroded or poorly installed, it breaks the seal and allows sewer gases to escape into the bathroom.
Under the Toilet
The bolts you see on the base of the toilet aren't screwed to the floor but are connected to a metal or plastic ring called the toilet flange. The ring is screwed to the floor and has a pipe attached to it that is glued to the waste line. It mates with the bottom of the toilet by means of a wax ring that fits inside it and compresses against the bottom of the toilet. The wax ring makes the seal, and when it breaks, water and gas can escape. It can break if the flange is damaged or set incorrectly.
The underside of a toilet is moist, and moisture can eventually corrode a metal flange. The part of the flange most susceptible to damage is the thin section that holds the toilet bolts. When it breaks, the bolts don't hold the toilet securely, and it can rock. When it does, it breaks the wax ring seal. Once the seal is broken, the problem can quickly worsen as water leaks out after every flush and further corrodes the flange and seeps into the subfloor, which can become spongy. The broken seal also allows sewer gases to escape.
Improperly Installed Flange
In order to compress the wax ring, the surface of the flange must touch, or nearly touch, the bottom of the toilet. To do this, it has to be at the same level as the floor. Sometimes, homeowners install new flooring and neglect to raise the flange to compensate for it. If it's too low, the wax ring may be too thin to make a seal. If, on the other hand, the flange is too high, the toilet rocks on it, and this can also break the seal. In either case, you'll smell sewer gases.
What To Do
Get to the bottom of a smelly toilet problem by removing it and inspecting the flange and subfloor. If the flange is too high, you may have to shim around the base of the toilet to stop it from rocking. If it's too low, you can add a flange extension to bring it up to the correct height. There are repair kits that allow you to fix a damaged or corroded flange without replacing it. Before you work on the flange, though, thoroughly check the subfloor to make sure it isn't water-damaged and can still support the toilet.