Tuesday, January 15, 2013

Sửa lỗi chạy MYSQL trên CentOS

Error occure when using command  :

# mysql  -u root -p

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)



Are you sure you installed mysql as well as mysql server.. ?
For example to install mySql server I'll use yum or apt to install both mysql command line tool and the server:
#yum -y install mysql mysql-server
or #apt-get install mysql mysql-server
Enable the MySQL service:
#/sbin/chkconfig mysqld on
Start the MySQL server:
#/sbin/service mysqld start
afterwards set the MySQL root password:
#mysqladmin -u root password 'new-password' (with the quotes)

Try :#mysql -u root -p
 
hope this help.
References : stackoverflow