MySQL/Laravel 5 migrations not working – SQLState 2002

If you have recently installed MySQL via Homebrew and Laravel via Composer you may run into some trouble where your migrations won’t run regardless of whether or not the credentials are correct.

To fix this add your unix_socket to your config/database.php file. Find out where your MySQL socket is by accessing the MySQL console.

mysql -u root;
show variables like '%sock%';

This will show you the location of your MySQL socket. Mine was “/tmp/mysql.sock”. Next access your config/database.php file and add this line to the end of your MySQL block:


Run your migrations and you should be good to go.

About Nick

Melbourne based web developer that loves Laravel, Ruby on Rails, Phoenix/Elixir, Writing, Travel, Jiu-Jitsu and Starcraft.

www ·

Leave a Reply

Your email address will not be published.