LARAVEL on ubuntu PDOException SQLSTATE[HY000] [2002] No such file or directory

It will ask you for the related password. Then once you get the mysql promt type the next command:

mysql> show variables like '%sock%'

and this script in file .env

DB_SOCKET=/opt/lampp/var/mysql/mysql.sock

source : https://stackoverflow.com/questions/20723803/pdoexception-sqlstatehy000-2002-no-such-file-or-directory