That's not how mines work. They don't only explode on people you want them to explode on.
That’s not fundamental to how mines work. You could arm/disarm them remotely, either manually or via transponder. But I assume most mines are not like this.
Easy: you mine the straight except the water immediately near your shores, where you can control the boat. We don't know about the mining part (the straight may or may not be mined yet) but the second part is what the Iranians are doing right now (the tankers which cross are doing to between Qeshm Island and mainland Iran, not in the straight proper)
I'm not a military guy, but I would think you can make mines nowadays that do exactly that.