In order to replace a T&P relief valve, shut off the water and power, and let the water cool for at least a few hours. Open an upstairs faucet and the tank’s drain valve. You don’t need to empty the entire tank, just drain it to a point below the valve fitting. Take out the overflow pipe from is outlet. Then use a pipe wrench to unscrew the old valve from the tank. Coat the new valve’s threads with pipe-thread sealing tape, and tighten it into the heater. Stop when the valve’s outlet points straight down. Screw the overflow pipe into the valve’s outlet, and turn the water back on. Bleed all air from the tank through an upstairs faucet, and turn on the power.