MariaDB & systemctl issue: /tmp/mysql.sock is within the PrivateTmp

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
9,158
This is more of an FYI until we sort out a solution.

By default, we have MySQL setup the mysql.sock in:
Code:
/tmp/mysql.sock
The problem is that the fancy systemctl feature:
Code:
PrivateTmp=true
will create a hidden jail for the given process, so it's version of /tmp may differ from other services.

The current easy workaround is to edit:
Code:
/etc/systemd/system/mysqld.service
/etc/systemd/system/httpd.service
/etc/systemd/system/php-fpm*.service
/etc/systemd/system/directadmin.service
etc..
and anything else that needs access to MySQL/MariaDB, and set:
Code:
PrivateTmp=false
Then reload the systectl daemon and restart all services
Code:
systemctl daemon-reload

This is not my preference, but would at least all you to get past the issue for now.

A related error might look like
Code:
Error: 2002 - No such file or directory

The fix we'll most likely use will be to move the .sock file to:
Code:
/usr/local/mysql/data/mysql.sock
which would be /home/mysql/mysql.sock with the default symlinks.

John
 
Update:

I've now changed the DA binaries, compiled date April 29th and later to point to:
/usr/local/mysql/data/mysql.sock

CB2 will now use the above mysql.sock path for php compiles on any Debian 8 system with systemd.
That being said, you must use CustomBuild 2.0 with Debian 8, and Debian 8 must be using systemd.

The /etc/systemd/system/mysqld.service now has this line:
Code:
ExecStart=/usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid [COLOR=#008000]--socket=/usr/local/mysql/data/mysql.sock[/COLOR]
The --user=mysql part was removed, as it was redundant to the User=mysql setting.

John
 
Some problems with install of MariaDB:

1. There's no password configured for the root user.
2. Because of the non-default location of mysql.sock the mysql and mysqladmin commands aren't working. They need the parameter --socket /usr/local/mysql/data/mysql.sock

I suggest adding the following to /etc/my.cnf by default:
Code:
[client]
socket=/usr/local/mysql/data/mysql.sock
 
::1 and 127.0.0.1 are not set for other systems either. We rely on "localhost".
Also make sure ::1 is not set to "localhost" in the /etc/hosts file, as that confuses some services by default.. eg: dovecot isn't bound to ipv6 by default (although CB2 checks for ipv6=1 in the directadmin.conf, and does enable it for dovecot, if DA has it turned on)
John
 
I tried the suggestions in this thread but i am still getting the following error:-

Code:
./build mariadb
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/data/mysql.sock' (2)
mv: 'mariadb-5.5.43-linux-x86_64.tar.gz' and '/usr/local/mariadb-5.5.43-linux-x86_64.tar.gz' are the same file
Stopping mysqld ...
-e Stopping mysqld:             [ FAILED ]
Synchronizing state for mysqld.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d mysqld defaults
Executing /usr/sbin/update-rc.d mysqld enable
-e Starting mysqld:             [ OK ]
Giving mysqld a few seconds to start up...
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/data/mysql.sock' (2)
FATAL ERROR: Upgrade failed
Restarting MySQL.
 
Please help!

No matter what I do I get the following error when trying to login to MariaDB.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
ERROR 1045 (28000): Access denied for user 'da_admin'@'localhost' (using password: YES)
 
Update:

I've now changed the DA binaries, compiled date April 29th and later to point to:
/usr/local/mysql/data/mysql.sock

CB2 will now use the above mysql.sock path for php compiles on any Debian 8 system with systemd.
That being said, you must use CustomBuild 2.0 with Debian 8, and Debian 8 must be using systemd.

The /etc/systemd/system/mysqld.service now has this line:
Code:
ExecStart=/usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid [COLOR=#008000]--socket=/usr/local/mysql/data/mysql.sock[/COLOR]
The --user=mysql part was removed, as it was redundant to the User=mysql setting.

John


i dont know but i have a default 8.3 debian, default install but i still need to put the PrivateTmp=false , otehrwise it would not start

this is line i have in the file

ExecStart=/usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid --socket=/usr/local/mysql/data/mysql.sock

o and the default root pass was empty..;/
 
could this be becuase i have an mounted tmpfile as tmp with these options?
/var/tmpMnt /tmp ext2 loop,noexec,nosuid,nodev,rw 0 0

i had to put the PrivateTmp=false to these services:

system/dovecot.service
system/httpd.service
system/exim.service
system/mysqld.service
system/clamd.service
 
and now i find out the the admin user is missing?
i really start to regret to even try debian.. its the second time last year i had the same experience.
endless hours of troubleshooting did anyone ever finished the debian install flawless?

really?

root@xxxx:/usr/local/directadmin/data/users# ls -lah
total 8.0K
drwx--x--x 2 diradmin diradmin 4.0K Feb 10 13:04 .
drwx--x--x 8 diradmin diradmin 4.0K Feb 10 16:15 ..

sigh so need to start from scratch again as i cannot trust the install..
so whatabout the debian install can i take this seriously?
 
Last edited:
This must have been the cause. Feel free to open a ticket in tickets.directadmin.com for a free installation on debian8.
 
Update:

I've now changed the DA binaries, compiled date April 29th and later to point to:
/usr/local/mysql/data/mysql.sock

CB2 will now use the above mysql.sock path for php compiles on any Debian 8 system with systemd.
That being said, you must use CustomBuild 2.0 with Debian 8, and Debian 8 must be using systemd.

The /etc/systemd/system/mysqld.service now has this line:
Code:
ExecStart=/usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid [COLOR=#008000]--socket=/usr/local/mysql/data/mysql.sock[/COLOR]
The --user=mysql part was removed, as it was redundant to the User=mysql setting.

John

I upgraded to Debian 8, but I've to do a symlink on every mysql restart:

ln -s /tmp/mysql.sock /usr/local/mysql/data/mysql.sock

Otherwise php can't connect to mysql...
 
I upgraded to Debian 8, but I've to do a symlink on every mysql restart:

ln -s /tmp/mysql.sock /usr/local/mysql/data/mysql.sock

Otherwise php can't connect to mysql...

Similar problem, but now i need to do
ln -s /home/mysql/mysql.sock /tmp/mysql.sock

Because "admin backups util" tries to use /tmp/mysql.sock (looks like this value is hardcoded into dataskg)
 
Similar problem, but now i need to do
ln -s /home/mysql/mysql.sock /tmp/mysql.sock

Because "admin backups util" tries to use /tmp/mysql.sock (looks like this value is hardcoded into dataskg)

Fixed by adding
Code:
[client]
socket=/usr/local/mysql/data/mysql.sock

to the /etc/my.cnf file
 
Back
Top