Check out example codes for "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)". It will help you in understanding the concepts better.

Code Example 1

sudo chown -R _mysql:mysql /usr/local/var/mysql

sudo mysql.server start

Code Example 2

> ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
> service mysql start or service mysql start

Code Example 3

Try to start the MySQL server:
mysql.server start

Learn ReactJs, React Native from