I am new to mysql and trying to install it on ubuntu 24.04. After a successful installation, when i am trying to connect mysql server through following command :
mysql -h localhost -u root -pit throws error like :
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)as suggested by @pumpkin :
output of sudo systemctl status mysql :
× mysql.service - MySQL Community Server Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Thu 2025-04-17 14:38:19 IST; 6min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 38517 ExecStartPre=/usr/share/mysql-8.4/mysql-systemd-start pre (code=exited, status=0/S> Process: 38557 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE) Main PID: 38557 (code=exited, status=1/FAILURE) Status: "Server shutdown complete (with return value = 1)" Error: 98 (Address already in use) CPU: 3.363sApr 17 14:38:17 mysqld[38557]: 2025-04-17T09:08:17.462000Z 0 [System] [MY-013602] [Server>Apr 17 14:38:17 mysqld[38557]: 2025-04-17T09:08:17.472575Z 0 [ERROR] [MY-010262] [Server]>Apr 17 14:38:17 mysqld[38557]: 2025-04-17T09:08:17.472639Z 0 [ERROR] [MY-010257] [Server]>Apr 17 14:38:17 mysqld[38557]: 2025-04-17T09:08:17.472784Z 0 [ERROR] [MY-010119] [Server]>Apr 17 14:38:19 mysqld[38557]: 2025-04-17T09:08:19.266926Z 0 [System] [MY-010910] [Server>Apr 17 14:38:19 mysqld[38557]: 2025-04-17T09:08:19.267010Z 0 [System] [MY-015016] [Server>Apr 17 14:38:19 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAI>Apr 17 14:38:19 systemd[1]: mysql.service: Failed with result 'exit-code'.Apr 17 14:38:19 systemd[1]: Failed to start mysql.service - MySQL Community Server.Apr 17 14:38:19 systemd[1]: mysql.service: Consumed 3.363s CPU time.Please help and explain why this error showing in my system ? and how to solve it ?