1. BEFORE THE SHOW
Truthfully, this is not a good time to talk to most musicians. Most of them are really only thinking about THE SHOW coming up, even if they are veterans and have done hundreds or trillions of gigs. Artists get nervous like anyone else, even if they are on 3' tall platform boots and spitting fire onstage. They will often be getting their calming/sociable drink or smoke on, and this process should not be interrupted lest nerves lead to vomiting on the front row. Also, do not interrupt a musician if he or she is cramming down the free food provided backstage as it probably is terrible and getting interrupted by a stranger while eating your free terrible food is doubly irritating.
But if you have nothing of any import to impart, feel free to go ahead and politely tell him or her that you are a big fan, love their work, saw them in 'Nam, or just say HI and shake hands and ask for an autograph or selfie if you wish. Just remember that they will remember absolutely nothing of this meeting, not even 30 minutes later when you try to get your niece's butt signed.
2. DURING THE SHOW
I shouldn't have to tell you that this is by far the WORST time to talk to a musician. But it is inevitable at any show that some fan will feel that this is the BEST time to talk to a musician, particularly if there is a quiet musical passage occurring and said fan is wasted. Please understand: no musician wants you to try to have a conversation with them while onstage. Ever. THEY ARE BUSY. This is not the time to tell Johnny Americana that one of his songs really helped you get through your barium enema last week.
Keep in mind as well that most musicians are wearing in-ear monitors or earplugs and CANNOT HEAR YOU. When you feel the need to shout, "WE LOVE YOU, MAN!" the musician will generally look confused or alarmed, because what they heard might have been, "SHE GLOVED A VAN!" Do not confuse the musician. Do not startle the musician. No no.
3. AFTER THE SHOW
This is another iffy time to talk to musicians, as they are transitioning from performance mode back into regular mode, and will be reviewing their show in their minds and scoping out backstage for attractive people. They also will probably be very sweaty. Some musicians just want to grab the last of the free beer backstage, get it loaded in the van and get the hell out of Dodge; some, after toweling off, might be relaxed and ready to hang out and chat. Etiquette note: if the musician is sitting at the merch table after the show, do feel free to chat a little if the line isn't too long, but be sure to BUY SOMETHING. Chatting at merch without buying is gauche, so buy a badge or something, tightwad.
That's pretty much it. You can always hope (if you live in a major music city) that you might run into your favorite musician buying kitty litter at the supermarket (known as The Danzig Encounter™), and you will have this natural conversation over clumping vs. non-clumping litter that leads to a mutual and long-lasting connection between two creative souls, but for most of us, meeting a musician will be limited to the above parameters. So go forth with the information you now have and get your personal groove on to the next level of fandom, which, if all goes well, will last around 3.2 seconds.
Me and Kurt Vile, before the show, 2011.