Is it legal/ethical to use data grabbed from a Stack Exchange site in a paper? For example, I download all the content of Academia@SE, later analysis it in a data mining paper, and submit the paper in the end. Is it OK to do so? Do I have to ask the permission from the administrator of the website? And does he or she have rights to forbid my academic use? Thank you.
Your University may have an Institutional Review Board (IRB) that reviews how you conduct experiments. This board may be known by various names (Ethics Committee, Experiment Review Board, Human Subjects Research, etc.) but they are generally the ones that you would go to to consult about whether what you are doing is within the scope of ethical behavior and good treatment of human subjects data.

As StackOverflow and associated StackExchange repository data is available under Creative Commons Attribution Share-Alike (as @piotr_migdal linked above) and is publicly available, your IRB will probably tell you, "It's fine" and not require review. However, it depends on the IRB and the institution and the nature of the data.

There are entire research disciplines built on scraping web sites, software repositories, and social media, so don't feel bad for doing it.