if you are new to installing mysql server you might probably face this error quite often if you type mysql in the shell prompt.
> mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
To fix:
First start the mysql daemon, then type mysql
> /etc/init.d/mysqld start
> mysql
Bingo! It worked for me!
To update mysql root password
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
To add a new user to mysql
1. First login as root then create a database ‘demo’
> mysql -u root -p
Enter password:
mysql> create database demo;
After that create a new user named ‘guest’ with password ‘guest’ with all previleges assigned to demo database;
mysql> GRANT ALL PRIVILEGES ON mytest.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
Then exit mysql and connect through username guest;
That should work!
Note: This could happen, if you run out of your disk space. Check your disk space.