I came across your question. It is common error for beginners. I can tell you the reason behind your above mentioned laravel 5 error is the caching-issue of your .env.php file this is because the Laravel 5 is using your environment based on the configuration mentioned in your .env file.
You just need to follow below steps to fix the error.
1. You need to go to the application root directory and open the .env file. If you are in the ubuntu then it may be hidden so just press ctrl+h to show the hidden files & if that is not the case and you are in the terminal then you need to type :
ls -a to show the hidden files in the editor and simply update database configuration setting as shown below and then save your .env file
2. After that restart the apache web server and try to refresh your page and you are done
3. If still you are facing the issue then you need to run below command to clear your old config cache file.
php artisan config:clear
After executing above command you are done with the error