Right. As Zoe said, the Cinque Terre is a collection of 5 villages strung out along about 7 miles. They are (from closest to La Spezia to furthest away): Riomaggiore, Manarola, Corniglia, Vernazza and Monterosso. Each of them have a train station, and all but Corniglia are also accessible by ferry during the warmer months.
Corniglia also involves a long climb on foot or a short ride on a little bus that zips up and down the hill between village and train station.
You can explore the train schedules on the Trenitalia website:
http://www.trenitalia.com/tcom-en
Each individual journey (one point to another) should cost about 4 euros (there are a few exceptions for the "fast" trains which travel through the region) and you must validate each single ticket before boarding the train: fines are high if caught with an unvalidated ticket.
There are Cinque Terre MS Treno cards which will cover unlimited 2nd-class journeys by train between La Spezia and Levanto (the five villages are between these two) plus use of the main hiking route for either 1 or 2 days. It also covers the little bus up/down from Corniglia. If using one of these cards, you only have to validate it the first time you use it.
http://www.parconazionale5terre.it/page.php?id=158
You can purchase these at the Welcome Center in La Spezia.
http://www.parconazionale5terre.it/Ecentri-visita-dettaglio.php?id=524
Riomaggiore is only 7 minutes from La Spezia, and the other villages are only a few minutes apart. Trains run quite early in the morning until late into the evenings.