If you want to greet a person in Japanese, say "Konnichiwa". (Actually this word is only suitable for the time period from midday till 6 p.m. If it's evening already, say "Kombanwa": "kon" - this, now; "nichi" - day, "ban" - evening; "wa" - is.) How to thank people?
If a friend helps you, you may say just "Arigatoo", "Doomo" or "Doomo arigatoo"
If a teacher, a boss of an unknown person helps you, you'd better say "Doomo arigatoo gozaimas".
But if he or she nearly saves your life, it's better to pronounce the longest form "Doomo arigatoo gozaimashita".
If you've done something wrong, say "Sumimasen".
If you are really guilty and awfully sorry, and your interlocutor is higher in status, say "Doomo sumimasen" or "Mooshiwake gozaimasen".
And "Goodbye" is "Sayonara" in Japanese.