How do I kill Mettaton EX?

If you're really stuck on the fight, I suggest getting the Temmie Armor, which gives you +20 defense, +10 attack, extra invincibilty frames and passive healing of 1HP/turn.

To get it, get a ride with the riverperson to Waterfall. You'll be at Gerson's shop. From there, go east until you get to the room with the mushrooms that light up the path. From the southeast corner of the dead-end path starts a southward path towards Temmie Village, where you can buy the Temmie Armor after paying for the shopkeeper's college education.

In the fight itself, the main hazards are the bombs, which explode in a cross (think Bomberman) when shot. If the attack requires you to shoot them, move to the side immediately after doing so. If it doesn't, avoid them altogether.

Both these things combined should give you the edge you need to win.