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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You May Also Like