First of stop MySQL.

Move your files to the desired directory. Most of the time MySQL database files are located in:
/var/lib/mysql/
You can move them as followed:
mv /var/lib/mysql/* /yourdirectory/
You now have to edit your mysql configuration. The my.cnf file is most of the time located in:
/etc/ or /etc/mysql/
Find the section [mysqld] then add or edit the following lines:
datadir=/yourdirectory/
socket=/yourdirectory/mysql.sock
Thats it. Now you can start your MySQL server again.