5. If the function
$$
f(x)=\frac{1}{3} x^{3}-\frac{1}{2} a x^{2}+(a-1) x+1
$$

is decreasing in the interval $(1,4)$ and increasing in $(6,+\infty)$, then the range of the real number $a$ is ( ).
(A) $a \leqslant 5$
(B) $5 \leqslant a \leqslant 7$
(C) $a \geqslant 7$
(D) $a \leqslant 5$ or $a \geqslant 7$
5. B.

Notice that $f^{\prime}(x)=x^{2}-a x+(a-1)$ $=[x-(a-1)](x-1)$.
According to the problem, when $x \in(1,4)$, $f^{\prime}(x)0$.
Therefore, $4 \leqslant a-1,6 \geqslant a-1$.
Solving this, we get $5 \leqslant a \leqslant 7$.