Shut off the power, gas, and the cold-water supply valve. Place a bucket under the pipe connected to the temperature-pressure-release valve on the top or side of the tank. (This valve opens if the tank pressure gets too high.) Lift the valve's tab to let some water out, then let go.
If water keeps flowing, drain the tank partway, unscrew the old valve with a pipe wrench, and install a new one.
While the power and gas is off, drain a few gallons of water from your tank. Now, unscrew the rod with a 1 1/16-inch socket on the rod's hex head on top of the heater (or under its top plate).
If it's less than a half inch thick or coated with calcium, buy a new one, wrap its threads with Teflon tape, put it back in the tank, and tighten securely.
Caution: If you have an older tank that has never been properly maintained there's a chance this step could further damage your water heater. Some newer water heaters do not require this as well. Consult a professional if you're unsure.
Drain the remaining water in the tank into the bucket, then stir up the sediment on the tank's bottom by briefly opening the cold-water supply valve. Drain and repeat until clean water comes out of the hose. Close the drain cock, refill the tank, and turn its power back on.
Find the temperature dial on the side of the tank and unscrew its cover. The Consumer Product Safety Commission (CPSC) suggests 120 degrees -- however, this is primarily due to the avoidance of scolding children or the elderly. There are obvious energy efficiency benefits at 120 as well. We do not suggest a specific temperature, but to do more to protect against Legionella we suggest between 125 and 140.
For those terrified of Legionella but don't want to scold their hands (and don't mind a bit more expensive gas bill), we suggest adding a mixing valve to bring down the temperature to 125 and keep your water heater at 140.
Buy some self-sticking 3/8-inch-thick foam pipe insulation that matches the pipes' diameter. Slide the foam over the hot- and cold-water pipes as far as you can reach. Insulating the cold-water pipe prevents condensation in summer. Peel the tape and squeeze the insulation closed.
Wrap the side of the tank, and seal cuts with foil tape. Do not cover the tops of oil or gas heaters. Cap an electric heater with an oversize circle of insulation, and tape its edge securely to the side of the tank.
Tankless water heaters also require yearly servicing. Hard water and calcium buildup are still a problem and so yearly descaling can help extend life.
Like most of our cleaning actions, you need white vinegar (or just hire a professional). You will also need a submersible pump, a couple of hoses, and a couple of buckets.
Watch this video here for a complete explanation.