GithubHelp home page GithubHelp logo

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) about freebsd-nextcloud-setup-hardened HOT 6 CLOSED

samuel-emrys-blogs avatar samuel-emrys-blogs commented on August 18, 2024
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

from freebsd-nextcloud-setup-hardened.

Comments (6)

ChaosBlades avatar ChaosBlades commented on August 18, 2024 1

That isn't fixing the issue for me it is only slightly changing the error message.

I destroyed my old jail and created a fresh one. After editing the socket parameter on my.cnf here is the output.


 root@tst:~ # /usr/local/bin/mysqld_safe --datadir='/var/db/mysql' &
 [1] 95814
 root@tst:~ # 200625 17:54:17 mysqld_safe Logging to '/var/db/mysql/tst.err'.
 200625 17:54:17 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
 
 [1]    Done                          /usr/local/bin/mysqld_safe --datadir=/var/db/mysql
 root@tst:~ # mysql_secure_installation
 
 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
 In order to log into MariaDB to secure it, we'll need the current
 password for the root user. If you've just installed MariaDB, and
 haven't set the root password yet, you should just press enter here.
 
 Enter current password for root (enter for none):
 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
 Enter current password for root (enter for none):

As you can see the only thing that has changed is the number at the end of the error changing from a 2 to a 61. I have tried several times and I get the same thing every time.

Here is my my.cnf to show I have edited it correctly.

 #
 # This group is read both by the client and the server
 # use it for options that affect everything, see
 # https://mariadb.com/kb/en/configuring-mariadb-with-option-files/#option-groups
 #
 [client-server]
 port    = 3306
 socket  = /tmp/mysql.sock
 
 #
 # include *.cnf from the config directory
 #
 !includedir /usr/local/etc/mysql/conf.d/

from freebsd-nextcloud-setup-hardened.

samuel-emrys avatar samuel-emrys commented on August 18, 2024

Is this a brand new installation, or did you mount a non-empty directory into /var/db/mysql?

from freebsd-nextcloud-setup-hardened.

ChaosBlades avatar ChaosBlades commented on August 18, 2024

Not sure if you saw my post on the forum yet. More information there.
https://www.ixsystems.com/community/threads/how-to-manually-install-nextcloud-on-freenas-in-an-iocage-jail-with-hardened-security.72016/page-7

To answer your question, this is a fresh jail. It is an old FreeNAS install (the latest version though) but that shouldn't affect a jail. The error is reproducible by destroying the old jail and creating a new one and re-entering the commands. I did just try to rm -r the /var/db/mysql directory then start mysql again, run the installation command again, and I still get the same error.

from freebsd-nextcloud-setup-hardened.

samuel-emrys avatar samuel-emrys commented on August 18, 2024

I've been able to replicate your issue. This is interesting; this must have just popped up in the past few days because I tested almost this exact configuration a number of times without issue. This was normally caused by having a non-empty /var/db/mysql/ directory. Regardless, I have a quick fix for you. To get the server started, there are a couple of things to do:

  1. Modify the 'socket' parameter in /usr/local/etc/mysql/my.cnf, and change it from /var/run/mysql/mysql.sock to /tmp/mysql.sock. This isn't strictly necessary if you change in remaining references in the guide to /var/run/mysql/mysql.sock
  2. Run /usr/local/bin/mysqld_safe --datadir='/var/db/mysql' &. This should get the server started, from which point you should be able to execute mysql_secure_installation and get everything configured. From here on, service mysql-server start, stop, and status should be enough to manage the mysql service.

Hopefully this works for you. It did for me.

Edit: It is necessary to change the path in (1) to /tmp/mysql.sock. This is the path that mysql_secure_installation expects

from freebsd-nextcloud-setup-hardened.

ChaosBlades avatar ChaosBlades commented on August 18, 2024

I got it working. I didn't need /usr/local/bin/mysqld_safe --datadir='/var/db/mysql' &. After editing the my.cnf I just needed to service mysql-server start, then mysql_secure_installation, and it works.

Edit: Looks like the guide is already wording things correctly.

from freebsd-nextcloud-setup-hardened.

gdh123 avatar gdh123 commented on August 18, 2024

still having the issue. fresh jail 11.3

did
Modify the 'socket' parameter in /usr/local/etc/mysql/my.cnf, and change it from /var/run/mysql/mysql.sock to /tmp/mysql.sock

restarted mysql

-> not working, still error:

Enter current password for root (enter for none): ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2) Enter current password for root (enter for none):

according to the destination in error msq it seems the path did not get respected.

verified socket in my.cnf and it is pointing to /tmp/..

any idea?

solved by:
$ service mysql-server start $ mysql_secure_installation --socket=/tmp/mysql.sock

from freebsd-nextcloud-setup-hardened.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.