This is very easy to do.
Assuming the database on the remote server runs on the standard mysql port 3306, the following command will establish the tunnel.

ssh username@remoteserver -L2000:localhost:3306

If successfully logged in through ssh, you can then connect your mysql client to port 2000 on your local machine and
will be able to use the remote database just as if it was running on your local computer.┬áThe good thing – all traffic will be encrypted by ssh.

obviously the L2000 means the port to be used on your local machine and 3306 is the port that will be used on the remote machine.

Note you can also add -f paramter to the ssh call:
ssh -f username@remoteserver -L2000:localhost:3306
if you want ssh to run in the background.