Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have problem with starting up mysql. When I type

service mysql start

All I got is

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

How can I fix it?

share|improve this question
    
Have you tried running sudo service mysql start? What does service mysqld status say? Or mysqladmin -u root -p status. Also: How did you configure MySQL in my.cnf? Has it ever worked before? –  slhck Jul 30 '12 at 9:14
    
sudo service mysql start says audit_log_user_command(): Connection refused mysql: unrecognized service –  Jasmin Subasic Suba Jul 30 '12 at 9:25
    
What about the other questions of mine? –  slhck Jul 30 '12 at 9:49
    
Wait -- isn't the service called "mysqld" (with a trailing "d" for "daemon")? that would explain the "unrecognized service mysql", right? So try: sudo service mysqld start instead. –  Izzy Jul 30 '12 at 13:14
add comment

1 Answer

First check the status of the service

[root@localhost ~]# service mysqld status

mysqld is stopped

[root@localhost ~]# su - max
Password:

If service is stop, that time you are getting these type of error

 
[max@localhost ~]$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Now start the service

[max@localhost ~]$ su -
Password: 
[root@localhost ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

Now check the status of the service

[root@localhost ~]# service mysqld status
mysqld (pid  6157) is running...
[root@localhost ~]# exit
logout
[max@localhost ~]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.