A search for a charged Higgs boson is performed with a data sample corresponding to an integrated luminosity of 19.7 +/- 0.5 fb(-1) collected with the CMS detector in proton-proton collisions at root s = 8,TeV. The charged Higgs boson is searched for in top quark decays for m(H +/-) < m(t) - m(b), and in the direct production pp -> t(b)H-+/- for m(H +/-) > m(t) - m(b). The H-+/- -> tau(+/-)nu(tau) and H-+/- -> tb decay modes in the final states tau(h)+jets, mu tau(h), l+jets, and ll' (l =e, mu) are considered in the search. No signal is observed and 95% confidence level upper limits are set on the charged Higgs boson production. A model-independent upper limit on the product branching fraction B(t -> H(+/-)b) B(H-+/- -> tau(+/-)nu(tau)) = 1.2-0.15% is obtained in the mass range m(H +/-) = 80-160 GeV, while the upper limit on the cross section times branching fraction sigma(pp -> t(b)H-+/-) B(H-+/- -> tau(+/-)nu(tau)) = 0.38-0.025 pb is set in the mass range m(H)+ = 180-600 GeV. Here, sigma(pp -> t(b)H-+/-) stands for the cross section sum sigma(pp -> (t) over bar H+) + sigma(pp -> t (b) over bar H-). Assuming B(t -> H(+/-)b) = 1, an upper limit on sigma(pp -> t(b)H-+/-) of 2.0-0.13 pb is set for m(H +/-) = 180-600 GeV. The combination of all considered decay modes and final states is used to set exclusion limits in the m(H +/-)-tan beta parameter space in different MSSM benchmark scenarios.