Backend trying to connect to MySQL using wrong socket

For discussion of topics specific to MythTV on linux
Post Reply
LeKodeur2
Newcomer
Posts: 3
Joined: Tue Dec 27, 2022 9:43 am
Australia

Backend trying to connect to MySQL using wrong socket

Post by LeKodeur2 »

I'm trying to install MythTV 32 using the Mythbuntu Control Panel app in Ubuntu 22.04 LTS. All goes well until I get to the 'MythTV Backend Setup' step and click on the button. Some scripts are run, etc. and I eventually get a HMI that attempts to access MySQL ... and fails. The mythtvbackend-setup log shows MythTV tries to access MySQL using the mysqld.sock socket in /var/run/mysqld. However, the socket in /var/run/mysqld is named 'mysqlx.sock' (with mysqlx.sock.lock), not 'mysqld.sock' ... what the??? I believe it may have something to do with running under a X desktop perhaps (I'm running Gnome Metacity)? Any idea what's going on and how to 'fix' this? Many thanks :)
User avatar
dnalorernst
Developer
Posts: 103
Joined: Mon Feb 17, 2020 8:03 pm
Austria

Re: Backend trying to connect to MySQL using wrong socket

Post by dnalorernst »

The socket is defined in the mysql configuration files. What does the following statement in the command line report?

Code: Select all

grep -r '.sock' /etc/mysql
Additionally, the location of the socket file is defined by the mysql service:
Check the mysql.service for the location

Code: Select all

systemctl cat mysql
This gives for me, albeit I use MariaDB:

Code: Select all

ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld
User avatar
bill6502
Developer
Posts: 2299
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend trying to connect to MySQL using wrong socket

Post by bill6502 »

Hi,

Looks like Roland and I are replying at the same time. He beat me.

Guessing that you're running MySQL (not MaridDB) version 8.something. I don't
see the 'x' files on my host that runs MariaDB.

If I run systemctl stop mysql, then the mysqld directory in /run goes away (there's
really a symbolic from /var/run to /run).

Then, when I start it again (sudo systemctl start mysql), the
directory is created and both the mysqld and mysqlx .sock files
are created along with two lock files. You may need to do:
sudo mysql to get the files created, I'm did once.

I think you'll find where the 'x' file is defined with: sudo grep --recursive mysqlx /etc/mysql

Just as a test, I'd try stopping mysql, checking /run/mysqld and then
starting it. Again checking /run/mysqld. If all 4 files exist, then try MCP.
Last edited by bill6502 on Tue Dec 27, 2022 8:44 pm, edited 1 time in total.
Reason: Fix types.
LeKodeur2
Newcomer
Posts: 3
Joined: Tue Dec 27, 2022 9:43 am
Australia

Re: Backend trying to connect to MySQL using wrong socket

Post by LeKodeur2 »

Thank you both for your replies. Here are the responses:

Code: Select all

xbmc@xbmc-3:~$ sudo grep -r '.sock' /etc/mysql
/etc/mysql/debian.cnf:socket   = /var/run/mysqld/mysqld.sock
/etc/mysql/debian.cnf:socket   = /var/run/mysqld/mysqld.sock
/etc/mysql/mysql.conf.d/mysqld.cnf:socket	= /var/run/mysqld/mysqld.sock
/etc/mysql/my.cnf:socket=/var/lib/mysql/mysql.sock
/etc/mysql/my.cnf:socket=/var/lib/mysql/mysql.sock
/etc/mysql/my.cnf.fallback:# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

Code: Select all

xbmc@xbmc-3:~$ systemctl cat mysql
# /lib/systemd/system/mysql.service
# MySQL systemd service file

[Unit]
Description=MySQL Community Server
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
User=mysql
Group=mysql
PIDFile=/run/mysqld/mysqld.pid
PermissionsStartOnly=true
ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
ExecStart=/usr/sbin/mysqld
TimeoutSec=infinity
Restart=on-failure
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755
LimitNOFILE=10000

# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart.
Environment=MYSQLD_PARENT_PID=1
But none of these outputs really help. I tried running mysqld with the '--mysqlx=0' argument from terminal and, although it executed successfully, the /var/run/mysqld folder (which should contain the mysqld.sock) was not created (tried a few times - no sock :(). If I start the mysql service then the /var/run/mysqld folder gets automaticlly created, but with mysqlx.sock and associated lock files ... no mysqld.sock (Bill gets both! How did you get both Bill??? :? ).

As per Bill's suggestion, also tried:

Code: Select all

xbmc@xbmc-3:~$ sudo grep --recursive mysqlx /etc/mysql
/etc/mysql/mysql.conf.d/mysqld.cnf:mysqlx-bind-address	= localhost
/etc/mysql/my.cnf:# mysqlx=0
.. but that seems to just be setting mysqlx as the binding sock/address for 'localhost'. There is no 'mysqld-bind-address' option possible.

So, I'm thinking there are two obvious possibilities:
1. How to create both 'mysqld.sock' and 'mysqlx.sock' special files in /var/run/mysqld, or,
2. How to tell mythbackend to look for mysqlx.sock instead of mysqld.sock?
Any ideas?
LeKodeur2
Newcomer
Posts: 3
Joined: Tue Dec 27, 2022 9:43 am
Australia

Re: Backend trying to connect to MySQL using wrong socket

Post by LeKodeur2 »

Re-installed MySQL and still no luck. Only mysqlx.sock (and mysqlx.sock.lock) exist in /var/run/mysqld folder ... no mysqld.sock :(
Anyone to advise how to tell MythTV to look for mysqlx.sock instead of mysqld.sock?
User avatar
heyted
Senior
Posts: 301
Joined: Sun Jun 08, 2014 2:14 am
Location: South Florida
Contact:
United States of America

Re: Backend trying to connect to MySQL using wrong socket

Post by heyted »

...the socket in /var/run/mysqld is named 'mysqlx.sock' (with mysqlx.sock.lock), not 'mysqld.sock'...
I used MCP to install MythTV, and I have both mysqlx.sock and mysqld.sock with the corresponding lock file for each in /var/run/mysqld. I used a fresh installation of Ubuntu and allowed the PPA package to automatically install the MySQL software by selecting Primary Backend in MCP.
...Gnome Metacity...
I'd start with a fresh installation of the desktop version of Ubuntu or Xubuntu, and use the default desktop.
Ted | My blog
User avatar
bill6502
Developer
Posts: 2299
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend trying to connect to MySQL using wrong socket

Post by bill6502 »

@LeKodeur2, I don't know how you did the re-install of mysql, but purging the
old /etc/mysql files would be my choice. There were differences between my
.cnf files and yours that could be because my installation is at least 6 years
old. Also, make sure there aren't any local my.cnf files in your user, the root
user and user mythtv.
Post Reply