What is the best way to upgrade a MySQL version in a Linux Server
I found the question relevant, however it is answered before elsewhere 


You want to turn off you database (take the backup, but only for the reason of having a backup)  
Go to you config file (.ini), in there locate the datadir
take a copy of this directory, or make sure it is not removed when reinstalling
Reinstall, and check if everything works, make sure the datadir is the same


This is how i would do it, but i haven't tested this, so you might bump into issues

(this idea/theory is backup up by this guy) http://dacosta9.wordpress.com/2008/10/25/moving-data-files-to-another-disklocation-mysql-sql-server/

And from Server fault
https://serverfault.com/questions/68146