Changing MariaDB socket when hosting multiple DB [Ubuntu]

This falls between installation/support. I have nextcloud up and running, but every reboot I have a problem because it’s really not correct. (Ubuntu bionic, essentially barebone install without docker, etc)

I have been running freshrss, which uses the default mysql socket. The server config for nextcloud also uses that socket. What ends up happening is that apparmor ends up locking one out on reboot - so I have to remove apparmor, and everything is great until reboot, when the cycle repeats.

I’d like to get the DB and nextcloud working on a different socket, but don’t understand the full process. When I change mariadb’s socket in the /etc/mysql/mariadb.conf.d/50-server… folder, the next reboot of mariadb fails with the following(shown via Journalctl), and nextcloud is inaccessible

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

Clearly mariadb is attempting to use the original socket, but I don’t know where else to make the socket changes. Can anyone help?

You have to provide the right socket path in the Nextcloud configuration file (config.php) too. If you want to use a socket connection it should look similar to this:

  'dbname' => 'nextcloud',
  'dbtableprefix' => 'oc_',
  'dbtype' => 'mysql',
  'dbhost' => 'localhost:/<path-to-socket>/mysql.sock',
  'dbuser' => '<dbuser>',
  'dbpassword' => '<password>',

Thanks for the reply!

The weird part is that I’m not using the socket within the config. I.E:

‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost:3307’,

It’s using two distinct port numbers, and not using the socket location, at least in this php config file. But If I do change the socket, nextcloud stops working. journalctl shows mariadb doesn’t find the OLD [mysqld.sock] socket.

As far as I remember a socket connection is automatically be used if you want to connect to “localhost”. You can try to use “127.0.0.1” or the external host name/ip address of your server if you want to force a tcp connection.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.