0

After installing Mariadb on Debian 9, I am trying to run /usr/bin/mysql_secure_installation. The script starts okay, but after I press 'enter' for no root password, I get the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

I have to ctl-c to get out of the script.

The socket is set in /etc/mysql/debian.cnf to /var/run/mysqld/mysqld.sock It is also set in /etc/mysql/mariadb.conf.d/50-server.cnf to /var/run/mysqld/mysqld.sock

The server is not running.

Barb H.
  • 61
  • 1
  • 7
  • visit this URL- https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run – Kandy Jan 07 '19 at 06:17
  • Possible duplicate of [ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)](https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run) – Kandy Jan 07 '19 at 06:19
  • I agree that there are a lot of posts with this error, and I browsed many of them going down a rabbit hole of checking config files. I felt it would be useful to have a question with the answer about starting the server when all configs are correct. – Barb H. Jan 07 '19 at 06:22
  • First you need check status. Is mysql running or not? Then Check file permission /var/run/mysqld/mysqld.sock – Ashish Kalekar Jun 09 '22 at 19:01

1 Answers1

0

After digging around many, many places, the answer was right under my nose on the Troubleshooting Connection Issues page at the MariaDB website 1

The error means that the server is either not running or running on a different port, socket or pipe. Since I knew the server was not running, I started it with

/etc/init.d/mysql start

before running the script and no more problems with the error or the script.

Barb H.
  • 61
  • 1
  • 7