mistake=「過ち、間違い」
make a mistake~「間違いをおかす」
grammatical=「文法上の」
in grammar=「文法で」
I made a grammatical mistake.
「私は文法上の間違いをおかしました」
I made a mistake in grammar.
「私は文法で間違いをおかしまた」
ご参考まで
I thought the grammar I was using all this time was correct, but now I realize it wasn't.
この場合、次のような言い方ができますよ。
ーI thought the grammar I was using all this time was correct, but now I realize it wasn't.
「今まで正しいと思って使っていた文法が間違っていたことに気がついた」
grammar で「文法」
all this time「今まで」
ご参考まで!