The 'root' chord or the key, always has the number 1. Then the next chord would be number 2 etc - all the way up to number 7.
So a basic outline would be in the key of G:
1 - G (you can always do a 1/3 chord as well i.e. G/B)
2 - Am
3 - Bm
4 - C
5 - D
6 - Em
7 - F#m (or really it's a kind of diminished, or can be 5/7 i.e. D/F#)
So in our sequence above of 1, 4, 6, 5 (and in a major key), we could discover that in the Key of D, these notes would equate to D, G, Bm, A. In the key of B, these would be B, E, G#m, F# etc.
There are some much better explanations for this but here is my graph that I created to help me remember this system. So take a look at my table (check it for accuracy and do let me know!) And then get learning along with me. Unfortunately I played bass the other day in a band and got one note wrong that really agitated me (!!) so I'm learning and determined to get this under my belt... !!