First, keep in mind: to begin this type of earthworks you should achieve Level 30 of Digging.
In order to have your own underground mine you should equip a pickaxe, then use Dig a tunnel/Dig a tunnel upward/Dig a tunnel downward commands and dig your way to the precious resources.
Aside from that, always remember to reinforce the walls of the tunnel and supply your mine with support columns on time in order to prevent being buried alive.
Action “Reinforce Tunnel Walls” requires 4 boards and any hammer or a mallet.
Action “Construct a Supporting Column” requires 2 building logs and a hammer or a mallet.