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

Hello.

I've tried to setup and configure WordPress on FreeBSD 13. This is the tutorial that I've followed,but I haven't been able to complete it because a mysql error that I'm not able to fix :

https://techviewleo.com/install-wordpress-with-nginx-php-fpm-on-freebsd/

Everything was good until step 3: Install and Configure MariaDB on FreeBSD 13

I've saved all the commands that I have issued from that point with the error that I've got :

https://pastebin.ubuntu.com/p/3hHPjfN3H3/

someone can shed some light over the error that I'm getting ? thanks.
 
Your biggest problem is trying to use packages that have MySQL 5.7 as the default 'mysql'. Those will result in a conflict with the MariaDB client. The installation of the MySQL client causes the MariaDB client to be removed, removal of the client also removes the server.

You're getting a "Can't connect to" message probably because MariaDB isn't running, it got removed with the installation of those MySQL 5.7 based packages.

Base the whole thing on MySQL 5.7 if you want to use the official packages, or start building from ports with DEFAULT_VERSION+= mysql=10.5m in make.conf so everything lines up correctly.
 
Code:
marietto@marietto:/var/db/mysql # pkg install mysql57-client             

Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (1 conflicting)
- mysql57-client-5.7.38 conflicts with mariadb105-client-10.5.15_3 on /usr/local/bin/mysql
Checking integrity... done (0 conflicting)
The following 3 package(s) will be affected (of 0 checked):

Installed packages to be REMOVED:
mariadb105-client: 10.5.15_3
mariadb105-server: 10.5.15_3

New packages to be INSTALLED:
mysql57-client: 5.7.38

Number of packages to be removed: 2
Number of packages to be installed: 1

The operation will free 187 MiB.

Proceed with this action? [y/N]: y
[1/3] Deinstalling mariadb105-server-10.5.15_3...
[1/3] Deleting files for mariadb105-server-10.5.15_3: 100%
==> You should manually remove the "mysql" user. 
==> You should manually remove the "mysql" group 
[2/3] Deinstalling mariadb105-client-10.5.15_3...
[2/3] Deleting files for mariadb105-client-10.5.15_3: 100%
==> You should manually remove the "mysql" user. 
==> You should manually remove the "mysql" group 
[3/3] Installing mysql57-client-5.7.38...
[3/3] Extracting mysql57-client-5.7.38: 100%
=====
Message from mysql57-client-5.7.38:

--
This is the mysql CLIENT without the server.
for complete server and client, please install databases/mysql57-server


marietto@marietto:/var/db/mysql # pkg install mysql57-server


Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
mysql57-server: 5.7.38

Number of packages to be installed: 1

The process will require 140 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Installing mysql57-server-5.7.38...
===> Creating groups.
Using existing group 'mysql'.
===> Creating users
Using existing user 'mysql'.
===> Creating homedir(s)
[1/1] Extracting mysql57-server-5.7.38: 100%
=====
Message from mysql57-server-5.7.38:

--
Initial password for first time use of MySQL is saved in $HOME/.mysql_secret
ie. when you want to use "mysql -u root -p" first you should see password
in /root/.mysql_secret

MySQL57 has a default /usr/local/etc/mysql/my.cnf,
remember to replace it with your own
or set `mysql_optfile="$YOUR_CNF_FILE` in rc.conf.


marietto@marietto:/var/db/mysql # service mysql-server enable
mysql enabled in /etc/rc.conf


marietto@marietto:/var/db/mysql # service mysql-server start
Starting mysql.

marietto@marietto:/var/db/mysql # service mysql-server status
mysql is not running.
 
Which version of mariadb is compatible with mysql57 ?
They all are. But that's not going to change the package conflicts you're going to have with regards to using a different version of mysql than the default.

The official packages are going to use MySQL 5.7. You cannot change those dependencies. The only way is to build those packages from ports yourself.
 
I don't understand what to do :

cd /usr/ports/databases/mariadb105-client

make


......

Installing mariadb105-client-10.5.15_2...

pkg-static: mariadb105-client-10.5.15_2 conflicts with mysql57-client-5.7.38 (installs files into the same place). Problematic file: /usr/local/bin/mysql
 
They all are. But that's not going to change the package conflicts you're going to have with regards to using a different version of mysql than the default.

The official packages are going to use MySQL 5.7. You cannot change those dependencies. The only way is to build those packages from ports yourself.
Try this ? Do you understand what SirDice is saying ?
 
no. I've tried to compile mariadb and mysql from ports,but I've got the same problem as I have using packages. They can't cooperate together. They are like USA and RUSSIA. He says to put "DEFAULT_VERSION+= mysql=10.5m" in make.conf. I've asked where is located make.conf,but he didn't reply,so I'm stuck.
 
I always connect through 127.0.0.1, port 3306 for mariadb & port 9000 for php-fpm, this makes it lot easier as no sockets are needed.

Do you mean to do like this ?

Code:
nano /usr/local/etc/mysql/my.cnf

[client-server]
port    = 3306
#socket  = /var/run/mysql/mysql.sock
!includedir /usr/local/etc/mysql/conf.d/

nano /usr/local/etc/php-fpm.d/www.conf

listen = 127.0.0.1:9000
;listen = /var/run/php74-fpm.sock;

Using this approach my hostname can be reached from outside of my LAN ? thanks.

The answer is no :

Code:
marietto@marietto:/usr/ports/databases/mariadb105-client # service mysql-server start
Starting mysql.

marietto@marietto:/usr/ports/databases/mariadb105-client # ps ax | grep mysql
35248  0  S+      0:00.00 grep mysql
 
Decide first if you want to compile from source yes or no ?
Because you don't know where make.conf is located, my advice would be, not to compile from source.
If you not compile from source you will be fixed to use mysql as default and cannot use mariadb client or server.
If you really want to compile from source you should spend first time on that specific issue, like most of us have done on this forum. I use for this poudriere. But note it's a learning curve.
Note freebsd is self-documenting, alot can be found by issuing the tools "man" or "apropos".
 
Do you mean to do like this ?

Code:
nano /usr/local/etc/mysql/my.cnf

[client-server]
port    = 3306
#socket  = /var/run/mysql/mysql.sock
!includedir /usr/local/etc/mysql/conf.d/

nano /usr/local/etc/php-fpm.d/www.conf

listen = 127.0.0.1:9000
;listen = /var/run/php74-fpm.sock;

Using this approach my hostname can be reached from outside of my LAN ? thanks.

The answer is no :

Code:
marietto@marietto:/usr/ports/databases/mariadb105-client # service mysql-server start
Starting mysql.

marietto@marietto:/usr/ports/databases/mariadb105-client # ps ax | grep mysql
35248  0  S+      0:00.00 grep mysql
Is 127.0.0.1 a routable IP-address ?
 
---> If you not compile from source you will be fixed to use mysql as default and cannot use mariadb client or server.

in this tutorial that I've read,he didn't compile anything from source,but he has installed mariadb client and server on freebsd 13 (I'm also using the same version of freebsd) and he has used mysql at the same time :


and for him everything works great. Is there anything that he didn't explain ? For me it's good to use mysql as default,so I will remove mariadb client and server. So this is what I did :

Code:
marietto@marietto:/usr/ports/databases/mariadb105-client # pkg remove mariadb105-server mariadb105-client


marietto@marietto:/usr/ports/databases/mariadb105-client # pkg install mysql80-server


nano /usr/local/etc/mysql/my.cnf


[client-server]

port    = 3306

socket  = /var/run/mysql/mysql.sock

!includedir /usr/local/etc/mysql/conf.d/


nano /usr/local/etc/php-fpm.d/www.conf


;listen = 127.0.0.1:9000

listen = /var/run/php74-fpm.sock;


again mysql is not actve :

marietto@marietto:/usr/ports/databases/mariadb105-client # service mysql-server start
Starting mysql.

marietto@marietto:/usr/ports/databases/mariadb105-client # ps ax | grep mysql

36366  0  S+       0:00.00 grep mysql
 
UPDATE :

Code:
marietto@marietto:/usr/ports/databases/mariadb105-client # pkg remove mysql80-server
marietto@marietto:/usr/ports/databases/mariadb105-client # pkg install mysql57-server
marietto@marietto:/usr/ports/databases/mariadb105-client # sudo mysql -u root -p

mysql: Can't read dir of '/usr/local/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
mysql: [ERROR] Fatal error in defaults handling. Program aborted!

marietto@marietto:/usr/local/etc/mysql # mkdir -p /usr/local/etc/mysql/conf.d/
marietto@marietto:/usr/local/etc/mysql # service mysql-server start
Starting mysql.
marietto@marietto:/usr/local/etc/mysql # sudo mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
 
again mysql is not actve :

marietto@marietto:/usr/ports/databases/mariadb105-client # service mysql-server start
Starting mysql.

marietto@marietto:/usr/ports/databases/mariadb105-client # ps ax | grep mysql

36366 0 S+ 0:00.00 grep mysql[/CODE]

Check the error log inside /var/db/mysql
 
Code:
marietto@marietto:/var/db/mysql # gedit marietto.err

2022-05-24 23:55:54 0x802612000  InnoDB: Assertion failure in thread 34399657984 in file ut0ut.cc line 921
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
21:55:54 UTC - mysqld got signal 6 ;

This could be because you hit a bug. It is also possible that this binary or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware. Attempting to collect some information that could help diagnose the problem. As this is a crash and something is definitely wrong, the information collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0

It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68147 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong...

stack_bottom = 0 thread_stack 0x40000
0x140eb88 <my_print_stacktrace+0x38> at /usr/local/libexec/mysqld
0x136a94e <handle_fatal_signal+0x2be> at /usr/local/libexec/mysqld
0x801e05e00 <_pthread_sigmask+0x530> at /lib/libthr.so.3

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

2022-05-24T21:55:54.6NZ mysqld_safe mysqld from pid file /var/db/mysql/marietto.pid ended
 
I've tried to compile mariadb and mysql from ports,but I've got the same problem as I have using packages. […] He says to put "DEFAULT_VERSION+= mysql=10.5m" in make.conf. I've asked where is located make.conf,but he didn't reply,so I'm stuck.
/etc/make.conf - you've got to create that file by yourself if needed. From mine:
jo@vacallinehae ~> grep mysql /etc/make.conf
DEFAULT_VERSIONS+=mysql=10.6m
 
Decide first if you want to compile from source yes or no ?
Because you don't know where make.conf is located, my advice would be, not to compile from source.
If you not compile from source you will be fixed to use mysql as default and cannot use mariadb client or server.
If you really want to compile from source you should spend first time on that specific issue, like most of us have done on this forum. I use for this poudriere. But note it's a learning curve.
Note freebsd is self-documenting, alot can be found by issuing the tools "man" or "apropos".
Did you read the last line ?
Don't get me wrong, sometimes i get the feeling you try to build a castle on a muddy ground. And then we should first search for a solid ground to build upon.
 
I don't want to be overhelmed by the study. I do this as an hobby,not as professionism. So I'm looking for the easiest / medium complexity solution. If I can resolve a problem walking for the short road,why I should not do that ? You told me that Its a good idea to don't compile by myself from source and I've agreed.

---> Are you certain you performed a diagnosis ?

No,I'm not sure. I'm groping in the dark and I'm not even tried to compile from source. But am I obliged to do this or I'm not ?
 
Am I doing right here ?

Code:
nano /etc/make.conf :

DEFAULT_VERSION+= mysql=10.5m

marietto@marietto:/usr/ports/databases/mysql57-server # make
 
Back
Top