Non-EU/EEA citizens must first apply for a study or research visa at the relevant German diplomatic mission before entering Germany. The Federal Foreign Office has set up an online platform, the Consular Services Portal, from which you can start the application process for your visa.
Citizens of Australia, Great Britain, Israel, Japan, Canada, New Zealand, South Korea and the United States of America as well as Andorra, Brazil, El Salvador, Honduras, Monaco and San Marino can enter Germany without a visa and obtain the required residence permit even after entering the country within the first three months of their stay in Germany. However, it is important to note that no gainful employment may be taken up during these 90 days. (You can find more information on this here.) The foreigners authority of the place where the foreigner will take up residence is responsible.
Detailed information on visa requirements can be found on the website of the Federal Foreign Office. You can find out about the various visa options in the Visa Navigator.
On the website “Make it in Germany” of the Federal Government you will find more detailed information, also on the visa for studying and the visa for research. The EURAXESS network has compiled an overview (in German) of the requirements and options for the various types of visa.