  The relevance of M dwarfs in the search for potentially habitable Earth-sized
planets has grown significantly in the last years. In our on-going effort to
comprehensively and accurately characterise confirmed and potential
planet-hosting M dwarfs, in particular for the CARMENES survey, we have carried
out a comprehensive multi-band photometric analysis involving spectral energy
distributions, luminosities, absolute magnitudes, colours, and spectral types,
from which we have derived basic astrophysical parameters. We have carefully
compiled photometry in 20 passbands from the ultraviolet to the mid-infrared,
and combined it with the latest parallactic distances and close-multiplicity
information, mostly from Gaia DR2, of a sample of 2479 K5V to L8 stars and
ultracool dwarfs, including 2210 nearby, bright M dwarfs. For this, we made
extensive use of Virtual Observatory tools. We have homogeneously computed
accurate bolometric luminosities and effective temperatures of 1843 single
stars, derived their radii and masses, studied the impact of metallicity, and
compared our results with the literature. The over 40000 individually inspected
magnitudes, together with the basic data and derived parameters of the stars,
individual and averaged by spectral type, have been made public to the
astronomical community. In addition, we have reported 40 new close multiple
systems and candidates rho < 3.3 arcsec and 36 overluminous stars that are
assigned to young Galactic populations. In the new era of exoplanet searches
around M dwarfs via transit (e.g. TESS, PLATO) and radial velocity (e.g.
CARMENES, NIRPS+HARPS), this work is of fundamental importance for stellar and
therefore planetary parameter determination.
