  A code over a finite field is called locally recoverable code (LRC) if every
coordinate symbol can be determined by a small number (at most r, this
parameter is called locality) of other coordinate symbols. For a linear code
with length n, dimension k and locality r, its minimum distance d satisfies a
Singleton-like bound. A code attaining this bound is called optimal. Many
families of optimal locally recoverable codes have been constructed by using
different techniques in finite fields or algebraic curves. However no optimal
LRC code over a general finite field of q elements with the length n around the
square of q, the locality r larger than or equal to 24 and the minimum distance
d larger than or equal to 9 has been constructed. In this paper for any given
finite field of q elements, any given r between 1 and q-1 and given d in
certain range, we give an optimal LRC code with length n around the square of
q, locality r and minimum distance d. This is the only known family of optimal
LRC codes with lengths n around the square of q and unbounded localities and
minimum distances d larger than or equal to 9. We also gives an asymptotic
bound for q-ary r locality LRC codes better than the previously konwn bound.
Many long r-locality LRC codes with small defects are also constructed.
