Consumer prices in January rose 3.1% from a year earlier, higher than economists had forecast, on higher food and housing costs.