Greetings,

I installed MySQL 5.1.48-2 on Fedora 13 64bit.

Whenever I tried to connect using the terminal by typing :
[user@work ~]$ mysql

I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I also installed MySQL on Red Hat Enterprise 5 and I still get the same error when I try to connect.

I Googled this problem but did not find a clear answer to this problem.
Is there a step after installation that I've missed?

Dani AI

Generated

A common and fast root cause for the socket error reported by is simply that no server process is present to create the socket (client-only installs will produce the same symptom). Other frequent causes are the server not running, a client/server socket-path mismatch, a stale socket file left behind, or LSM (SELinux/AppArmor) blocking socket creation.

Practical quick checks and commands:

# Start the server (SysV or systemd, depending on the distro)
sudo service mysqld start
sudo systemctl start mysqld
sudo systemctl status mysqld

# Confirm a server process and listening port
ps aux | grep -E 'mysqld|mariadbd' | grep -v grep
sudo netstat -plnt | grep 3306

If the server is running but the client still fails, verify the socket paths in server and client configs (my.cnf / /etc/mysql/*). Look for differing socket settings under [mysqld] and [client]. For a quick bypass, force a TCP connection instead of a socket:

mysql -h 127.0.0.1 -P 3306

Check the server error log (common locations: /var/log/mysqld.log or /var/log/mysql/) for startup problems (permission errors, failed datadir initialization). On older installs the server database may need initialization (e.g., mysql_install_db); on modern packages the installer normally does this.

Notes and cautions: do not remove a socket file while a running server owns it; use logs to diagnose startup failures; temporarily setting SELinux to permissive can help confirm an LSM issue but should not be left disabled. Enabling the server to start at boot and running the distribution's post-install helper (for example mysql_secure_installation or the distro-specific setup) completes a reliable setup.

Nevermind turns out I did not have mysql-server installed only the client.

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.