TRENDING
  • Linux
  • Shell Script
  • Cloud
  • DevOps
  • About US
SUBSCRIBE
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Reading: How to Fix cannot connect to local MySQL server through socket error on AlmaLinux / Rocky Linux
Share
TechBrownTechBrown
Aa
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Search
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Follow US
© 2014 - 2022 TechBrown. All Rights Reserved.
Linux

How to Fix cannot connect to local MySQL server through socket error on AlmaLinux / Rocky Linux

August 19, 2015
Share
3 Min Read
SHARE
Contents
Pre Steps after occurring the MariaDB installationsStep-I (Install the MariaDB)Step-II (Running MySQL Command)Step-III (Checking the Mariadb Service)How to fix this?Step-I (Start the Mariadb service)Step-II (Auto enable the Service)Step-III (Verify services are stared or not)

The issue is ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2 “No such file or directory”) error . This type of error occurred on AlmaLinux / Rocky Linux / Amazon Linux the fix provides the solve this errors.

Pre Steps after occurring the MariaDB installations

Step-I (Install the MariaDB)

On AlmaLinux / Rocky Linux / Amazon Linux

# yum install mariadb mariadb-server
Step-II (Running MySQL Command)

Firstly Check the mysql command for testing purpose.

# mysql
 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")
Step-III (Checking the Mariadb Service)

After that check the mariadb services

# systemctl status mariadb
 ● mariadb.service - MariaDB 10.0 database server
 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
 Active: inactive (dead)

How to fix this?

Step-I (Start the Mariadb service)

then start the mariadb services.

# systemctl start mariadb
Step-II (Auto enable the Service)

Finally Service started automatically.  Add the service as systemd system and service managers are on.

# systemctl enable mariadb
 Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
Step-III (Verify services are stared or not)
# systemctl status mariadb
● mariadb.service - MariaDB 10.0 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2015-08-19 21:46:13 IST; 8s ago
Process: 18042 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 17903 ExecStartPost=/usr/libexec/mysql-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 17710 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 17680 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 17901 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─17901 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─18012 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/m...
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: The latest information about MariaDB is available at http://mariadb.org/.
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: You can find additional information about the MySQL part at:
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: http://dev.mysql.com
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: Support MariaDB development by buying support/new features from MariaDB
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: Corporation Ab. You can contact us about this at [email protected]
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: Alternatively consider joining our community based development effort:
Aug 19 21:46:12 localhost.localdomain mysql-prepare-db-dir[17710]: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
Aug 19 21:46:12 localhost.localdomain mysqld_safe[17901]: 150819 21:46:12 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Aug 19 21:46:12 localhost.localdomain mysqld_safe[17901]: 150819 21:46:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 19 21:46:13 localhost.localdomain systemd[1]: Started MariaDB 10.0 database server.

Congratulations now you have fixed the cannot connect to local MySQL server through socket error on AlmaLinux / Rocky Linux / Amazon Linux.

You Might Also Like

How to Optimize MySQL Performance on AlmaLinux / Rocky Linux

How to Enable TLS 1.3 on Apache and Nginx

5 Security Tips to Protect your WordPress Website from Hackers

How to Enable AES-128 Bit SSL Cipher with TLS 1.3 on Nginx Web Server

How to Set Up NGINX Web Server on AlmaLinux / Rocky Linux

Sign Up For Newsletter

Be keep up! Get the latest articles delivered straight to your inbox.

TechBrown Solutions August 19, 2015
Share this Article
Facebook TwitterEmail Print
Share
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

TRENDING

Linux

How to Install Free SSL From Lets Encrypt on Shared Hosting

Linux

How to Install Sphinx-Doc on Ubuntu / AlmaLinux / Rocky Linux

DevOps

How to Setup Nagios Monitoring using AWS Cloud Formation on Ubuntu Instance

Linux

How to Configure Squid Proxy Server on AlmaLinux / Rocky Linux

You Might Also Like

Linux

How to Optimize MySQL Performance on AlmaLinux / Rocky Linux

October 19, 2021
Linux

How to Enable TLS 1.3 on Apache and Nginx

March 14, 2021
Linux

5 Security Tips to Protect your WordPress Website from Hackers

November 8, 2020
Linux

How to Enable AES-128 Bit SSL Cipher with TLS 1.3 on Nginx Web Server

November 7, 2020

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Twitter Youtube Rss

© 2014 - 2022 Techbrown. All Rights Reserved.

  • About Us
  • Terms of Service
  • Cookie Policy
  • Privacy Policy
By using this site, you agree to the Privacy Policy, Cookie Policy and Terms of Service.
Accept

Removed from reading list

Undo
AdBlock Detected
Our site is an advertising supported site. Please whitelist to support our site.
Okay, I'll Whitelist
Welcome Back!

Sign in to your account

Lost your password?