An optimal control problem is considered for a stochastic differential equation with the cost functional determined by a backward stochastic Volterra integral equation (BSVIE, for short). This kind of cost functional can cover the general discounting (including exponential and non-exponential) situation with a recursive feature. It is known that such a problem is time-inconsistent in general. Therefore, instead of finding a global optimal control, we look for a time-consistent locally near optimal equilibrium strategy. With the idea of multi-person differential games, a family of approximate equilibrium strategies is constructed associated with partitions of the time intervals. By sending the mesh size of the time interval partition to zero, an equilibrium Hamilton--Jacobi--Bellman (HJB, for short) equation is derived, through which the equilibrium valued function and an equilibrium strategy are obtained. Under certain conditions, a verification theorem is proved and the well-posedness of the equilibrium HJB is established. As a sort of Feynman-Kac formula for the equilibrium HJB equation, a new class of BSVIEs (containing the diagonal values $Z(r,r)$ of $Z(\cd\,,\cd)$) is naturally introduced and the well-posedness of such kind of equations is briefly discussed.