hi friends,

I'm trying to install mysql on linux through rpm. I have install it & when I'm I enter the command

mysqladmin -u root -p create mydb

its showing
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

so what is the problem. can anyone tell me. PLZ.

when i;m trying to connect its showing

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Dani AI

Generated

This error almost always means the server never created the Unix socket: either the daemon failed to start, the server is using a different socket path, the data directory wasn’t initialized or owned by MySQL, or the server was killed at startup (low memory, SELinux, etc.). That matches earlier hints: pointed at the service, reminded to confirm the server package is actually installed, and noted low RAM can make mysqld die before the socket appears.

Work through these checks (run as root or with sudo):

ps -ef | grep [m]ysqld
tail -n 80 /var/log/mysqld.log
grep -i socket /etc/my.cnf
ls -ld /var/lib/mysql
rpm -qa | grep -i mysql-server

If the data directory looks empty or contains only a socket file that disappears, the server may not have been initialized; for older MySQL use mysql_install_db (newer MySQL uses mysqld --initialize). If the server has a different socket path (client vs server mismatch), either adjust the config or create a short-lived symlink to test:

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

Two other common causes: SELinux and OOM (out-of-memory). Check SELinux mode with getenforce and look for AVC denials in /var/log/audit/audit.log. Check kernel messages for OOM kills (dmesg | egrep -i 'killed|oom'). Temporarily disabling SELinux (for troubleshooting only) or adding swap/memory can reveal the underlying failure.

If those checks don’t show the failure reason, capture and share the last ~50 lines of the mysqld log, the ps output above, and the exact CentOS and MySQL versions. That information makes the next troubleshooting step clear and avoids guessing.

Recommended Answers

All 10 Replies

what distor do you have?
in Mandriva use urpmi, Suse there is Yast or zypper ...et al

urpmi mysql

what distor do you have?
in Mandriva use urpmi, Suse there is Yast or zypper ...et al

urpmi mysql

Hi there,

I'm using centOS. so any idea ?

what distor do you have?
in Mandriva use urpmi, Suse there is Yast or zypper ...et al

Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

Probably your mysql service 'mysqld' is not running...
Check with...

service mysqld status

If not running, start with... (as root)

service mysqld start

To always activate the service on boot...

chkconfig mysqld on

On Fedora systems (CentOS is alike) you can activate via the Gnome menu: System - Administration - Services

still not working

what distor do you have?
in Mandriva use urpmi, Suse there is Yast or zypper ...et al

how do you install other stuffs like VLC media ?

Have you set a root password for MySQL? In a standard installation, the root password is empty. You first have to set it.

mysqladmin -u root password NEWPASSWORD

Check to see if you have the server and not just the client installed.

yum list | grep mysql

will list all of the packages and you can see what is installed. My centOS 5 systems listed the following:
[root@srvr3 ~]# yum list | grep mysql
mysql.i386 5.0.77-4.el5_4.1 installed
mysql.x86_64 5.0.77-4.el5_4.1 installed
mysql-bench.x86_64 5.0.77-4.el5_4.1 installed
mysql-devel.i386 5.0.77-4.el5_4.1 installed
mysql-devel.x86_64 5.0.77-4.el5_4.1 installed
mysql-server.x86_64 5.0.77-4.el5_4.1 installed
perl-DBD-mysql.x86_64 4. installed
php-mysql.x86_64 5.1.6-24.el5_4.5 installed

hey thanx to everyone for helping me to install mysql on linux successfully.

Also, in case anyone happens to stumble across this thread in google, that /var/lib/mysql/mysql.sock error also occurs when the process cant get enugh memory (256mb minimum, preferably 512mb+)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.