How to Fix "Xlib: No protocol specified"

While installing Oracle database I was getting this error. I searched various blogs and forums and found out many solutions but lastly I got one solution which worked for me. But well I will post