Can't log into mysql shell When I try to log into the mysql shell with:

mysql -u root


then I get:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


How do I log onto the mysql shell?

I have been googling this left and right and trying all those proposed solutions on stackoverflow and elsewhere but nothing seems to work.

I have tried adding -p at the end. Same error.

I have tried going by this:
https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run
The first answer, I already have mysql-server installed.
The second answer doesn't work.
The third answer, i cannot implement step no. 3:

mysql -u root


and in the second step the process just hangs with message:

mysqld_safe Logging to syslog.
2017-09-26T16:30:40.563159Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-09-26T16:30:40.566955Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.


So the question is, how do I log onto the mysql shell?
Please, review my.cnf files (see oficial documentation for file locations https://dev.mysql.com/doc/refman/5.7/en/option-files.html).

Search under the [client] section if exist an entry called socket, i.e:

[client]
port=3306
socket=/tmp/mysql.sock


Replace it with the right path to mysql.sock and try again.
To get the mysql.sock, use ps -FU mysql -H | more and get the --socket value