Write down important (even unimportant} passwords in three places - writing it on a red piece of paper taped to the ceiling is a good idea.
There are utilities that advertise their ability to recover FMP passwords, I would approach these with a hint of scepticism..
TSGal may way in on this discussion.
Losing a Master Password is a totally nooby mistake.
If your solution has had the master passwords (admin privileges) removed, by way of a developer protecting their work, then you will not be able to recover it, simply because there is no password to recover.
However if the admin privileges account has been left in place, you should find an answer as suggested by DavidAnders.
Again, proceed with caution, why... because these tools do not give you the original password, they will EDIT the file and write a new password under most circumstances. Therefore, do not expect to get a password from a copy / clone of your DB, then use it to open the original. This could possibly cause you some issues, such as corruption, who knows....