Kinetic theory and acoustic measurements have proven that the bulk viscosity associated with the expansion or compression effect cannot be ignored in compressible fluids except for monatomic gases. A new theoretical formula for the bulk viscosity coefficient (BVC)
$\unicode[STIX]{x1D701}$ is derived by the continuum medium methodology, which provides a further understanding of the bulk viscosity, i.e.
$\unicode[STIX]{x1D701}$ is equal to the product of the bulk modulus
$K$ and the relaxation time
$\unicode[STIX]{x1D70F}$ (
$\unicode[STIX]{x1D701}=K\unicode[STIX]{x1D70F}$). The continuum and kinetic theories present consistent results from macro- and microperspectives respectively, only differing in terms of a coefficient. The theoretical predictions of the BVC in diatomic molecules, such as
$\text{N}_{2}$,
$\text{O}_{2}$ and CO, show good agreement with the experimental data over a wide range of temperature. In addition, the vibrational contributions to
$\unicode[STIX]{x1D701}$ are controlled by a rapid exponential decrease at high temperatures, while at low temperatures a slow linear increase proceeds for the rotational cases. The relaxation time
$\unicode[STIX]{x1D70F}$, collision number
$Z$, BVC
$\unicode[STIX]{x1D701}$ and ratio of bulk-to-shear viscosities
$\unicode[STIX]{x1D701}/\unicode[STIX]{x1D707}$ in the vibrational mode are found to be several orders of magnitude larger than those in the rotational mode.