How do I connect to the MySQL server in the Nextcloud snap version on Ubuntu?

How do I connect to the MySQL server in the Nextcloud snap version on Ubuntu ?
The details in the config.php don’t seem to help … as the ‘sock’ does not exist ?

‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost:/tmp/sockets/mysql.sock’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,

For now, I am sqldumping and import into some other instance of MySQL, I would prefer to query against the ‘live on air’ sql server.

Can it even be done in the ubuntu snap version ?

Hello @CloudArchive.

I just want to understand what you are after. Why are you willing to connect to the database?

You are writing in the developer forums. Here the main connect is the development of nextcloud apps. In auch an app, you would use dependency injection and let the server so the actual DB connection.

If you are after the setup within the snaps, the question is more related to the administration of an instance. This is a different layer of abstraction then.


Thanks for response.

Ideally, considering that user management and reporting is severely lacking, I want to make an app that gives much better insight into what’s going on inside nextcloud and the users and clients. (Something like a drill down dashboard)

Okay, I will not go into the details of what is missing and needed in the core. You might want to have a look on what is planned and provide further suggestions for concrete enhancements.

This app I assume will be external to Nextcloud? You will need access to the database. As far as I understood the snap code (I just took a quick glance), the MySQL server is bundled and listens on a socket. So, no port is used to connect but a file inside the snap virtual file system.

If you can confirm this, there are only two options I see:

  1. Assignment the snap with your own app which will result in building your own snaps
  2. Getting rid of snap and using the services directly, e.g., through docker or installed bare metal.

Anyways, this discussion is off topic as this forum is about the development of nextcloud apps to be embedded (like deck, talk, files, calendar, polls, mobile tracker, etc). I cannot provide support on how to handle snap build or the like (because I simply do not know).