If your search results are sure to return paths with no spaces, you could use xargs like this:
locate my.cnf | xargs grep user (no search paths with blanks)
However you should get in the habit of protecting yourself to handle the case where a path or filename might contain a space by telling xargs to use null as a separator and telling locate (or whatever program you are using to return strings) to also send that as the separator like this:
locate -0 my.cnf | xargs -0 grep user (search paths with blanks)
Example path with blanks: "/name with space/my.cnf"
This would work even if your path included blanks like /name with space/my.cnf.