As mentioned in the previous reply.
The general rule is the [client] section to match what the [mysqld] section has for the socket file location, so if [mysqld] shows
socket = /tmp/mysqld.sock,
then [client] section should have
If [mysqld] has something else, like socket = /var/run/mysqld/mysqld.sock then [client] should have the same.
Note: Make sure to back up your my.cnf file before applying any changes.
cp /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
cp /etc/my.cnf /etc/my.cnf.bak