The term store is not stored in the content database. It's a responsibility of the Managed Metadata Service.
You question - how can I migrate term store from one farm to another?
Here is what I found useful to read and use:
Migrating managed metadata term sets to another farm on another domain - the article clearly explains what happens with metadata value in the columns when you restore content db on the another farm. Essentially, you will not loose metadata value in the lists, but you can't use it further until you migrate related term store.
Article also provides a means to migrate your term set and how do you reconnect the term store to the content via PowerShell - http://sptermstoreutilities.codeplex.com/
But in case of migration to SharePoint Online manually, the only option you left with - is Import CSV file of term set to the destination - SPOnline.
The provided PowerShell script exports the term site into CSV file.
The pitfall of importing CSV file , you can't specify child-parent relationship between term sets.