mysql.sock missing: php connection works but cant connect from terminal
First you need to check your MySQL config file my.cnf and make sure it contains socket parameter

[client]
socket=/var/mysql/mysql.sock

[mysqld]
socket=/var/mysql/mysql.sock


if those parameters not presented then you need to add them and start MySQL service.

after that you need to change MySQL folder permission sudo chmod -R 755 /var/lib/mysql/ and make sure it is owned by MySQL user.

finally start MySQL service.

Note: you need to make sure ports are opened for MySQL inside firewall