Hi, I am a professional certified mechanic, with an engineering background, and 35+ years experience. I will do my best to assist you. Also keep in mind I don't know if you are a pro or a novice, so feel free to add any additional info at any time.
What you need to do is to contact a Mazda dealer with your VIN number for a radio code. When the battery goes dead, or gets too low the electronics in the radio assume the radio has been disconnected/removed/stolen. Basically the radio always has power to it, so it should normally see a no or low power situation. It has an anti-theft system that shuts the radio down in a low power situation, assuming it has been stolen/disconnected. You need to get the code and enter it. Most Mazda radios only allow 3 attempts to enter the code then they require a secondary code. It's a pain, but it is what it is, and it is what you have to deal with to get it going. Also there is no trick, or bypass all straight up pain in be backside, LOL. Get with Mazda, get the code, and you can get through this. Good luck with it, have a great day, and Thanks for using Just Answer.
I do not get paid for my work unless you rate at 3 to 5 Smiley Faces or Stars, a bonus is always greatly appreciated. If the answer is not clear, let me know what additional help you need, and I will be happy to assist you further.