Hi Susan,
there are 2 trains a day to Naples from Cinque terre, the trip takes 7-8 hours. It may be easier to get the train to salerno for visiting the Amalfi coast (which is actually the bay of Salerno) and from there you can get the regular boats to most towns - Amalfi (and Ravello) , Minori, Maiori, Cetara etc. there is also a coastal bus service (buy tickets before you get on the bus and validate on the bus) which is fun! Rome2rio and Man in seat 61 are 2 excellent websites for info on train travel in Europe.
enjoy beautiful Italy
gip