Fortunately the people at MariaDB have provided a nice step by step installation which should work. I've done this in the past, so if you have any problems. Drop a comment with the error, I'll try to help.
Guide can be found here.
I would recommend testing this first before doing this on a production system, as there are small details that can be missed.
With regards to upgrading MySQL, assuming you're using a standard Linux dist using the commands:
sudo apt-get upgrade
sudo apt-get install
Should appropriately upgrade MySQL binaries.
Although major version updates should be done per recommendation of the application.