Gram is the unit of weight and it comes under CGS measurement. CGS stands for centimeter for length, gram for mass and seconds for time whereas MKS system contains meter for length, kilogram for mas and seconds for time.
1 gram contains 1000 milligram such as:
For the conversion of gram to milligram,

Thus, 5000 mg is present in 5 g of compound