The complex formed by the tetracycline (TC) molecule with the Mg ion is able to prevent the replication of the genetic material in the bacterial ribosome, making an excellent antibiotic. In general, the absorption and emission spectra of TC are very sensitive to the host ions and the pH of the solvent that the set is immersed. However, the theoretical absorption spectrum available in the literature is scarce and limited to simple models that do not consider the fluctuations of the liquid. Our aim is to obtain the electronic absorption spectrum of TC and the complex Mg:TC in the ratio 1:1 and 2:1. Moreover, we analyze the changes in intensity and shifts of the bands in the systems listed. We performed the simulation using the classical Monte Carlo technique with the Lennard-Jones plus Coulomb potential applied to each atom of the both TC molecule and the Mg:TC complexes in water. The electronic absorption spectrum was obtained from the time-dependent density functional theory using different solvent models. In general, we obtained a good qualitative description of the spectra when compared with the experimental results. The Mg atom shifts the first band by 4 nm in our models, in excellent agreement to the experimental result of 4 nm. The second absorption band is found here to be useful for the characterization of the position where the ion attaches to the TC