I was getting some error while execute mysql.

It's just socket error.

If you have /tmp/mysql.sock but no /var/mysql/mysql.sock then...

# cd /var
# mkdir mysql
# cd mysql
# ln -s /tmp/mysql.sock mysql.sock

If you have /var/mysql/mysql.sock but no /tmp/mysql.sock then

# cd /tmp
# ln -s /var/mysql/mysql.sock mysql.sock

You will need permissions to create the directory and link, so just prefix the commands above with sudo if necessary.

you got this site :