How much do my career prospects suffer if I start a mathematics/CS PhD. at the age of 27? I was doing a PhD in a different subject and that was going nowhere and I lost interest in everything that I was doing. But I always loved mathematics and during the dark days of my 3rd of my (former) PhD. I happened to meet some exceptional theoretical CS people who encouraged me a lot. One of them got me as a TA and I am starting afresh in this new field. 

How optimistic should I be about a career ahead? 

I want to be a researcher/faculty.
How much do my career prospects suffer if I start a mathematics/CS PhD. at the age of 27?


Not at all. 27 is not considered "old" by any stretch of the imagination.

Also see this answer on MathOverflow and this question here on Academia about a PhD student who is actually unusually old.