We report on the inclusive production cross sections of J/psi, psi(2S), gamma(1S), gamma(2S) and gamma(3S), measured at forward rapidity with the ALICE detector in pp collisions at a center-of-mass energy root s = 8 TeV. The analysis is based on data collected at the LHC and corresponds to an integrated luminosity of 1.23 pb(-1). Quarkonia are reconstructed in the dimuon-decay channel. The differential production cross sections are measured as a function of the transverse momentum p(T) and rapidity y, over the p(T) ranges 0 < p(T) < 20 GeV/c for J/psi, 0 < p(T) < 12 GeV/c for all other resonances, and for 2.5 < y < 4. The cross sections, integrated over p(T) and y, and assuming unpolarized quarkonia, are sigma(J/psi) = 8.98 =/- 0.04 =/- 0.82 mu b, sigma(psi(2S)) = 1.23 +/- 0.08 +/- 0.22 mu b, sigma(gamma(1S)) = 71 +/- 6 +/- 7 nb, sigma(gamma(2S)) = 26 +/- 5 +/- 4 nb and sigma(gamma(3S)) = 9 +/- 4 +/- 1 nb, where the first uncertainty is statistical and the second one is systematic. These values agree, within at most 1.4 sigma, with measurements performed by the LHCb collaboration in the same rapidity range.