unable to connect mysql

Posted by bersam on 2012/2/27 9:47:25
Os: centos
yum install httpd mysql php-mysql php phpmyadmin

and set 3 priviliage for localhost in phpmyadmin with different password
then i cant connec in mysql with php or phpmyadmin

[root@localhost ~]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


then remove phpmyadmin , mysql , php and re install them
but i cant connect in mysql again

then try to reset password

http://www.rhel.in/2011/03/recoveringresetting-mysql-password-in.html

but i cant connect in mysql again

[root@localhost ~]# /etc/init.d/mysqld stop
/etc/init.d/mysqld: line 16: .: /etc/sysconfig/network-scripts: is a directory
Stopping mysqld:                                           [  OK  ]
[root@localhost ~]# vi /root/mypassreset.sql
[root@localhost ~]# mysqld_safe --init-file=/root/mypassreset.sql &
[1] 12212
[root@localhost ~]# 120227 16:40:08 mysqld_safe Logging to '/var/log/mysqld.log'.
120227 16:40:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120227 16:40:14 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
[1]+  Done                    mysqld_safe --init-file=/root/mypassreset.sql
[root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
[root@localhost ~]# service mysqld start
/etc/init.d/mysqld: line 16: .: /etc/sysconfig/network-scripts: is a directory
Starting mysqld:                                           [  OK  ]
[root@localhost ~]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

This Post was from: https://www.centos.org/newbb/viewtopic.php?forum=56&topic_id=36030&post_id=155972