This question is not to mattermost, and the question to your database management system. Usually the database migration described in the description of the normal documentation.
It looks something like this -
Stop services mattermost
manipulate the database
Run mattermost.
If the database you want to move within the server you can simply Relink catalog database to a new location