Can I mix up formula in a bottle and put it in the fridge?

My baby hates warm formula as I never use to warm the water but then I read it’s important to boil the water to kill bacteria.

Is it OK if I boil the water, mix the formula and then put it in the fridge? And how long is it good in the fridge?