Multiplicities in semi-inclusive deep-inelastic scattering are presented for each charge state of \pi^\pm and K^\pm mesons. The data were collected by the HERMES experiment at the HERA storage ring using 27.6 GeV electron and positron beams incident on a hydrogen or deuterium gas target. The results are presented as a function of the kinematic quantities x_B, Q^2, z, and P_h\perp. They represent a unique data set for identified hadrons that will significantly enhance our understanding of the fragmentation of quarks into final-state hadrons in deep-inelastic scattering.