[+] Inicio | [+] Contacto | [+] Blog



SOLUCIÓN: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

$ date | cat c4t3g0ry;
- - Publicado el 09/09/2014 | Esto es sobre: Unix/Linux Sys.Admin

Recientemente mi novia instalo en una Maquina virtual Kali Linux, cómo sabemos es un debian, este error ya me había salido hace muchas lunas atrás eh aquí otra solución:

root@kali:~ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@kali:~ mysqladmin password newpassword
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
root@kali:~ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Al parar y prender nuevamente el demonio me salió un [info] el cual menciona que algunas tablas estaban corruptas:

root@kali:~ ps ax | grep mysql
12528 pts/0    S+     0:00 grep mysql
root@kali:~ service mysql start
[ ok ] Starting MySQL database server: mysqld ..
[info] Checking for tables which need an upgrade, are corrupt or were
not closed cleanly..
root@kali:~ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@kali:~ /etc/init.d/mysql status
[info] /usr/bin/mysqladmin  Ver 8.42 Distrib 5.5.38, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2014, 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.

Server version          5.5.38-0+wheezy1
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 2 min 57 sec

Threads: 1  Questions: 576  Slow queries: 0  Opens: 421  Flush tables: 1  Open tables: 41  Queries per second avg: 3.254.

A lo cual decidí apagar el demonio de mysql y usar el script de arranque de mysql.

root@kali:~ service mysql stop
[ ok ] Stopping MySQL database server: mysqld.
root@kali:~ mysqld_safe --skip-grant-tables &
[1] 13184
root@kali:~ 140908 14:45:55 mysqld_safe Logging to syslog.
140908 14:45:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
root@kali:~ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.38-0+wheezy1 (Debian)

Y listo… nuestro demonio de mysql corre perfectamente, ya queda la configuración de la contraseña y ciertas cosas que dependen de cada uno.

Saludos