Solving MySQL 5.7 authentication method problems in Laravel

2024-02-12 #mysql #laravel

Last week I was setting up al old Laravel project that required MySQL 5.7. I installed DBngin so I could have the legacy MySQL version up and running alongside the modern MySQL 8. Smooth sailing so far, until my Laravel app wanted to connect to the database.

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

It took some googling to find a solution that worked. Most solutions recommended changing the authentication method in MySQL, but this was already configured correctly for me. What I had to do was explicitly configure a socket for MySQL to connect with. I added the following to my .env file:

DB_SOCKET=/tmp/mysql_3307.sock

Replace 3307 with the port number you configured your MySQL server to run on.


Using MySQL `order by` while keeping one value at the end

2021-12-16 #mysql #laravel

The other day I needed to sort a dataset in MySQL and ensure one value was always at the end. I never fully understood how order by works, so I did some research on how to solve my problem and how order by behaves.

Read more