my phone had an issue with charging cables falling out. Turns out the port had compacted lint jammed in it. Turned the phone off and used a needle to clean it all out, phone retains cables now like the day it was new.
I don't even bother turning my phone off, but it's rated as water resistant and so I am pretty confident that there aren't any voltages present when disconnected. Even on non-waterproof phones, though, any voltage persistently applied to pins on an external connector will result in corrosion over time, so it shouldn't be a problem to just mechanically scrape gently with a dry metal needle.