You need to inform the server and mysql clients that they will communicate exclusively through a socket. To do this, open the my.cnf configuration file and set the path to the socket in the socket directive in two sections: [client] for clients and in [mysqld] for the server (add these if there are no directives)
[client] ... socket = /var/run/mysqld/mysqld.sock ... [mysqld] ... socket = /var/run/mysqld/mysqld.sock ...
After that, restart the server.
sudo service mysql restart
and make sure that the socket file appears in the / var / run / mysqld / folder. I do not advise placing the file in / tmp, since from there it can be regularly removed by cron-cleaning tasks and you will again and again encounter this error (the / var / run directory itself is intended for sockets and pid-files).
If you plan to work through a socket, you can generally disable network access, even locally. To do this, in the [mysqld] section of the my.cnf configuration file, install the skip-networking
directive
[mysqld] ... skip-networking