0

Ubuntu Server 20.04 and Nextcloud server installed with Snap(https://github.com/nextcloud-snap/nextcloud-snap).

I need to connect to Nextcloud MySQL DB inside Snap and make SELECT on some tables, but I don't understand how to do it with python.

If I'm using standard CLI utility, everything is fine.

sudo nextcloud.mysql-client -S /tmp/sockets/mysql.sock

But I don't understand how to do the same thing with python and dedicated MySQL user.

I've tried to use 'subprocess.check_output' route, but it turns out to be a terrible idea...

Any suggestions?

1 Answers1

0

Snap stores the /tmp directory under:

/tmp/snap-private-tmp/

So the socket you're looking for there is actually under:

/tmp/snap-private-tmp/snap.nextcloud/tmp/mysql.sock

Or on 22.04 LTS, mysqlx.sock

However you can't actually use this socket file to connect to connect to the Nextcloud instance because of the way Snap's sandboxing works.

mysql -S ./mysqlx.sock
ERROR: 

I think the best workaround is probably:

  1. Re-build the nextcloud-snap to use TCP 127.0.0.1:3306 for access to MySQL
  2. Migrate from the snap based deployment to traditional deployment.

Personally, when I first started using Linux around 25 years ago this book was one of the first ones that I read and really liked:

enter image description here

Note the Subtitle: Making Easy Things Easy & Hard Things Possible

In my limited experience working with snap, it consistently makes easy things hard, and it completely diverges from everything else that I understand about Linux in it's own extremely proprietary way.

If I must deal with a container, docker is far less troublesome. I expect Ubuntu LTS as a common server standard will eventually be undone by their instance on snap.

erwin
  • 442
  • 6
  • 13