04/08

Laravel 5.0 Sqlstate HY000 2002 Error

Mysql Connection Problem

So with a new version of software comes new issues to tackle, this time it was for the database.php file in the Laravel version 5.0, so there is a new field added in the `mysql connection that is specifying the socket to be used.

If you have used a vagrant machine like me, in the older versions of Laravel i.e 4.2 and below there was no field specifying the unix_socket so you might have login in you vagrant machine and run the following

mysql -uhomestead -psecret
mysql> show variables like '%sock%';
+---------------+-----------------------------+
| Variable_name | Value |
+---------------+-----------------------------+
| socket | /var/run/mysqld/mysqld.sock |
+---------------+-----------------------------+
1 row in set (0.00 sec)

The socket displayed in the above query is the one we need to be using in our database.php file for it, once this is done your database will be connected to the correct unix socket and will be working fine.

END
UP NEXT