Saturday, May 16, 2009

Solution for: Could not connect to host 'localhost'. MySQL Error Nr. 2002.

After installing Mysql we face some minor problems, one of them is:

Could not connect to host 'localhost'. MySQL Error Nr. 2002 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'


So the easy solution for it is that open terminal and login as root:
su

enter root password.
Type:
/etc/init.d/apache2 start

apache2 some time refer to httpd, it depends on distro.
And now try to login to Mysql.

Tip: For each boot up to start Mysql service automatically, Open Yast2, click on Run level, and enable Mysql service there. (This tip is for openSUSE).

For Mandriva: Open 'Configure your computer' and select System and click on 'Manage system services by enabling and disabling them' and enable mysqld there.

ANL

No comments: