A search for narrow resonances and quantum black holes is performed in inclusive and b-tagged dijet mass spectra measured with the CMS detector at the LHC. The data set corresponds to 5 fb(-1) of integrated luminosity collected in pp collisions at root s = 7 TeV. No narrow resonances or quantum black holes are observed. Model-independent upper limits at the 95% confidence level are obtained on the product of the cross section, branching fraction into dijets, and acceptance for three scenarios: decay into quark-quark, quark-gluon, and gluon-gluon pairs. Specific lower limits are set on the mass of string resonances (4.31 TeV), excited quarks (3.32 TeV), axigluons and colorons (3.36 TeV), scalar color-octet resonances (2.07 TeV), E-6 diquarks (3.75 TeV), and on the masses of W' (1.92 TeV) and Z' (1.47 TeV) bosons. The limits on the minimum mass of quantum black holes range from 4 to 5.3 TeV. In addition, b-quark tagging is applied to the two leading jets and upper limits are set on the production of narrow dijet resonances in a model-independent fashion as a function of the branching fraction to b-jet pairs.