First of all you might want to tell us that you want to learn this because you want to know how a hacker thinks, to be able to protect your self and others from being attacked I guess? ;) Data breaches are illegal and in many cases you get a pretty juicy fine to pay, or in some cases you might end up in jail depending on breach type.
But if you want to learn the legal way and stay a whitehat hacker to help people you can check those two sites. Just download Vmware or virtualbox and then follow instructions on one or both of the links below. That’s how you can set up a safe environment to practice any hacking method you like without damaging someone elses property. Good luck, and have fun!
http://www.itsecgames.com/
http://www.dvwa.co.uk/
There is a lot of youtube tutorials on how to set this up.
Allso if you want, you can download Kali linux and install on a virtual machine and use as the “attacking” machine.
https://www.kali.org/