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

I have had no idea about programming and stuff
I recently joined this platform…
I went through the steps and installed MYSQL in my system but I have no idea what this problem is saying
I am pretty basic to these stuff.
Can anyone explain what exactly this means and what is the solution to this problem


Does mysql service is running?

What is the result of this command?
systemctl status mysql


I highly recommend this site for new Linux users.
It allows you to select a Linux OS variant and then it provides you with good instructions for getting many different services installed and configured.
As for your error, tell us how you are going to connect to this DB.
Will you access locally or remotely?
MySQL version 8+ ?

1 Like


  1. did you start the service?

Start MySQL Service and Enable at Loggin:

sudo systemctl start mysqld 
sudo systemctl enable mysqld 
  1. did you find the random password?

For security reasons, MySQL generates a temporary root key. Please note that MySQL has even stricter security policies than MariaDB.

sudo grep 'temporary password' /var/log/mysqld.log
  1. did you configure MYSQL?

Configuring MySQL before the first use

Type password you’ve got in step 2.

sudo mysql_secure_installation


you can also install via container using podman see References




@cjpembo Yes is quite usefull but in the case of MYSQL isn’t up-to-date I’m talking about the recently change introduced in MYSQL For security reasons, MySQL generates a temporary root key when installing.


1 Like

It says something like
Unit mysql.service could not be found.

I don’t know anything like that
I am beginner to database as well
I was told to install mysql just because it is popular among linux users according to ::::::

Now I need to install it but after following a YouTube tutorial I got this problem

I get the message like
Failed to start mysqld.service: Unit mysqld.service not found.
If I type : sudo systemctl start mysqld
and when I type : sudo systemctl enable mysqld
I get ==…Failed to enable unit: Unit file mysqld.service does not exist.
What I did was
sudo dnf install mysql-server
thats all I did

Have you followed the instructions provided by @hhlp?


@hhlp @alciregi
can we install mysql oracle and mariadb all ?
which is the best DBMS in yours terms and me being just a beginner what do you suggest ?
Do we get the gui interface in linux for DBMS ?
if not how do we install because it might get a little headache for me to use cli in the beginning
and can you give me some guide to use fedora?

@alciregi @hhlp
I think I have installed mysql successfully but the problem is I cannot find the gui interface
Is it available in linux
and what is the advantage of using terminal for DBMS ?

all thanks to: and @hhlp

For a GUI you should use something like MySQL Workbench or Dbeaver or PHPMyAdmin.
But it is a bit difficult here to assist you step by step from zero. Once installed and started the service, it is better to search some guide on internet.
In addition what is your goal? Having an RDBMS and interfacing to it with some programming language (i.e. Python, PHP)? Or the goal is to play with a database?


No., You can’t install BOTH

  1. phpmyadmmin is in the :fedora: main repo and you need apache too, and later access via web browser.
sudo dnf install phpMyAdmin
  1. dbeaver is available via flatpak
flatpak remote-add --if-not-exists flathub
flatpak install flathub io.dbeaver.DBeaverCommunity
  1. workbench is in mysql communty repo:
sudo dnf install mysql-workbench



i wanted to install mysql-workbench and phpmyadmin because both appealed me but can we install both because even after installing mysql workbench I didn’t get the application. I don’t know if this is only my problem. SO later I installed workbench and I got the application.
In your above statement I didn’t understand what apache means?
should we install it ?

Apache is a wer server and are required as dependencies for phpMyAdmin and acces later via web-browser, for example

http://(your hostname or IP address)/phpmyadmin/

That’s depended of your need…


1 Like

how to know our hostname?
and how do I install apache on fedora?
what is the meaning of wer server?

hostname is → localhost ( or the machine Ip address that host the service (ip add show)

A web server is server dedicated to running that can satisfy client requests for example database server.

  1. What is your principal reason to acomplish this task?, just for playing, if is it the reason with workbench and dbveaer are well enough is depend of your needes.

What can i do with:


1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.