I am having a database connection error

Every 3 or 4 days MySQL server stops running and I have to restart it.

I found this error: DBI connect failed : Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

Not sure how to go about fixing this.

Perhaps try this solution…

https://tableplus.com/blog/2018/08/solved-cant-connect-to-local-mysql-server-through-socket.html

Or there are a whole heap of alternative fixes on stackoverflow…

https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq

Check your mysql error log for the exact problem. Try in /var/log or check your /etc/my.cnf.