Database Settings

The Database options for digiKam are set from Settings ‣ Configure digiKam… ‣ Database page.

Nota

For an introduction to internal data storage, please refer to the Database section of the Getting Started chapter.

The SQLite Database

SQLite is a relational database management system, written in the C programming library. SQLite is not directly comparable to client/server SQL database engines such as MySQL, Oracle or PostgreSQL. Rather, it is an SQL database engine that is embedded in an end program. SQLite reads and writes directly to ordinary disk files. SQLite is almost always the best solution for device-local storage with low write-concurrency and less than a terabyte of content. SQLite is fast and reliable and it requires no configuration or maintenance. It keeps things simple. SQLite «just works».

By default, digiKam uses SQLite as its back-end for storing important metadata and thumbnails. digiKam stores information into four SQLite files:

Banca dati

Nome del file

Principale

digikam4.db

Miniature

thumbnails-digikam.db

Somiglianze

similarity.db

Volti

recognition.db

To keep your application running fast and smooth, you should periodically check and optimize your databases: select Tools ‣ Maintenance… and then Perform Database Cleaning. See the Database Cleaning section of the Maintenance Tools chapter for details.

The SQLite Browser, is a high quality and easy to use visual tool for managing database objects, that we highly recommend. For Ubuntu and its derivatives, it can be installed using sudo apt install sqlitebrowser. Then you can switch to the directory where the digiKam databases are stored in order to visualize the database contents.

Nota

For best performance, store the digiKam databases on the fastest hardware (such as SSD or NVMe) with plenty of free space. This is especially important for the thumbnails database. A remote file system such as NFS cannot be used here. For performance and technical reasons, SQLite cannot use media from the network.

The SQLite database files can be found in the collection folder that you added to digiKam. (By default, if you add your “Pictures” collection, the database files will be present in the ~/Pictures folder).

La pagina di configurazione SQLite di digiKam

The WAL SQLite mode is a very important option that we recommend you turn on with large databases to optimize transactions and improve performance.

La banca dati MySQL

MySQL a confronto con SQLite

MySQL is an open-source, relational database management system, written in C and C++. Original development of MySQL by Michael Widenius and David Axmark began in 1994. Sun Microsystems acquired MySQL in 2008, which was later acquired by Oracle in 2010. MySQL currently works on almost all system platforms (Linux, Microsoft Windows, OS X, SunOS …).

MariaDB server is a community-developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.

MariaDB use has overtaken MySQL for a few basic reasons:

  • Lo sviluppo di MariaDB è più aperto e vibrante.

  • Ha più funzionalità all’avanguardia.

  • Più motori di archiviazione.

  • Migliori prestazioni.

  • Compatibile e semplice da migrare.

digiKam also provides support for the popular MySQL database engine. Of course, you might wonder why you’d want to switch to MySQL when SQLite already does a good job of managing the data? MySQL offers many advantages for storing digiKam data, especially when collections include more than 100,000 items. With such large collections, SQLite introduces latency which slows down the application.

Nota

With WAL option enabled, SQLite can be easily used for more than 100,000 items especially with an SSD or NVMe storage. It may be even faster than MySQL and more stable. See this page for technical details.

Using MySQL as digiKam’s database back-end allows you to store the data on local as well as remote servers. MySQL Internal can be used to replace the local SQLite storage, and MySQL Server can be used on media stored on a remote server. This way, you can use multiple digiKam installations (for instance, on your notebook and PC) to access and manage your photo collections. You can also use MySQL tools to backup and analyze digiKam’s data.

Per passare dalla banca dati di SQLite a quella di MySQL, vai a Impostazioni ‣ Configura digiKam… e nella sezione Banca dati seleziona una banca dati dall’elenco a tendina.

  • MySQL interno: permette di avviare un server per la banca dati interno al tuo sistema. digiKam utilizza il socket di Unix per la connessione.

  • MySQL Server: Use this if your data is on a remote server and you’re on a different machine trying to access the collection.

Il server MySQL interno

digiKam tends to slow down when using a large collection (size greater than 100,000 items) hosted on a hard drive (HDD - not an SSD or NVMe device) with the SQLite database. To avoid the delay and maintain efficiency, digiKam provides the option of using MySQL Internal. To be clear, this isn’t an actual server, or a public network. Instead, it is a server that runs only while the application is running.

Il server interno crea una banca dati separata cui si può accedere (solo quando l’applicazione è in esecuzione) utilizzando il comando:

mysql --socket=/home/[user_name]/.local/share/digikam/db_misc/mysql.socket digikam

The internal server uses three MySQL Binary Tools: mysql_install_db, mysqladmin, and mysqld. You can configure their locations in the configuration dialog. digiKam will try to find these binaries automatically if they’re installed on your system.

La pagina di configurazione del MySQL interno di digiKam

Il server remoto MySQL

Obviously, access to a MySQL server is required to use digiKam with a remote MySQL. Alternatively, you can install MariaDB, which serves the purpose well. (Could be installed easily using this link.)

Follow the instructions below, if you don’t have a dedicated user account and a digiKam database already set up. Run the commands in MySQL server, after replacing password with the correct one.

Nota

Puoi selezionare un qualsiasi nome per la banca dati (qui è semplicemente digikam, ricordati solo di compilare correttamente il nome della banca dati principale, di quella per le miniature, di quella per i visi e per le somiglianze nella finestra mostrata qui sotto.

CREATE USER ''@'%' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO ''@'%' IDENTIFIED BY 'password';
CREATE DATABASE digikam;
GRANT ALL PRIVILEGES ON digikam.* TO ''@'%';
FLUSH PRIVILEGES;

Nota

Se hai una raccolta molto grande, si raccomanda di avviare il server MySQL con mysql –max_allowed_packet = 128M

Suggerimento

If you have problems with a MySQL server on a Ubuntu based Linux system, execute this additional command in the mysql prompt to enable the creation of MySQL triggers.

SET global log_bin_trust_function_creators=1;

Now, in digiKam, go to Settings ‣ Configure digiKam… and then under the Database section, select MySQL Server from the drop down list.

La pagina di configurazione Mysql remoto di digiKam

Inserisci l’indirizzo IP del tuo server MySQL nel campo Nome host, e specifica la porta giusta nel campo Porta host (quella predefinita è la 3306).

Set the Core Db Name field to the name of the first database that is used to store photo metadata.

Set the Thumbs Db Name field to the name of the second database that is used to store the wavelet-compressed thumbnails.

Set the Similarity Db Name field to the name of the third database that is used to store the similarity finger-prints produced by the fuzzy search engine.

Set the Face Db Name field to the name of the last database that is used to store the face histograms for facial recognition.

To safely connect to the remote server, enter your MySQL identification using the User and Password fields.

To check whether the database connection works properly, press the Check Connection button. If everything works as it’s supposed to, switch to the Collections sections, and add the directories containing your photos. Hit OK, and wait till digiKam populates the databases with data from your photos. This can take a while if you have a lot of items to register in the database.

Ci sono alcuni suggerimenti e raccomandazioni per ottenere i risultati migliori con un server di banca dati remoto MySQL.

  • With a slow network, digiKam hangs a lot of the time, especially when the album contains many items (>1,000). This issue depends on network performances. For example, the problem has been reproducible using Wifi connections. Switching to Ethernet to solve the problem.

  • Inoltre, se hai una raccolta molto grande, dovresti avviare il server MySQL con mysql –max_allowed_packet = 128M (se sei esperto di MySQL puoi anche cambiare le impostazioni nei file my.ini, oppure in ~/.my.cnf files.

Avvertimento

The locale used in the Mysql server must be the same as the locale from the computer used to run digiKam to prevent problems with the common values saved in the tables of the database.

Criteri per il tipo di database

See the summary below to choose the right database type depending on your use case.

Archiviazione

Tipo

Elementi

Commenti

HDD

SQLite

< 100K

Attenzione: WAL è obbligatorio.

HDD

MySQL interno

> 100K

SSD

SQLite

WAL è facoltativo.

SSD

MySQL interno

NVME

SQLite

WAL è facoltativo.

NVME

MySQL interno

Rimovibile

SQLite

< 100K

Attenzione: WAL è obbligatorio. USB 3.1 è il minimo con un dispositivo NVMe.

Rimovibile

MySQL interno

> 100K

Attenzione: USB 3.1 è il minimo con un dispositivo NVMe.

Rete FS

SQLite

Proibito: le banche dati SQLite devono essere memorizzate in un sistema di file locale.

Rete FS

MySQL interno

Proibito: le banche dati MySQL devono essere memorizzate in un sistema di file locale.

Remoto

Server MySQL

È supportato il server MariaDB. Raccomandata Gigabit Ethernet o superiore.

HDD

Disco rigido (HDD).

SSD

Dispositivo a stato solido.

NVMe

Memoria non volatile.

Rimovibile

Dispositivo USB HDD/SSD/NVMe esterno.

Rete FS

Network File System montato localmente.

Remoto

Server di rete come NAS (Network Attached Storage).

WAL

Write-Ahead Lock (solo banche dati SQLite).

Nota

Refer the Digital Asset Management chapter for more details about media and data protection.

Also refer to the Collection Settings chapter for more details about how to configure your collections depending on your storage policy.

Importante

If you share the same Removable media for host databases and/or collections between different computers, you must have the same kind of operating system, the same mount paths everywhere (use symbolic links to resolve paths), and the same digiKam version everywhere to prevent conflicts with the database schema.

If you use a common Remote server to host databases and collections, you must use the same digiKam version everywhere to prevent conflicts with database schema. Computers running different instantiations of digiKam cannot access a common database and collection at the same time.

If you use a common Remote server to host collections, with the databases stored on individual computers, then different versions of digiKam can be used and digiKam sessions can run at the same time, accessing the common collections. But you’ll need to take a care about concurrent accesses to file metadata, if you have turned this option on from the Metadata Setup page.

Migrazione della banca dati

digiKam comes up with an exclusive tool named Database Migration, that allows users to migrate their data. For example, the migration tool can help you move all your data from a SQLite database into a MySQL database, or vice versa.

Per migrare a un’altra banca dati, vai al menu Impostazioni ‣ Migrazione della banca dati…. Comparirà un riquadro di dialogo:

Lo strumento di migrazione della banca dati di digiKam

Now choose the appropriate database types you want to convert to. Finally, click on Migrate button to convert the database from SQLite to MySQL (or vice versa). Depending on the database size, this operation can take a while.

Nota

Only the digiKam Core database will be migrated by this conversion process. All of the other databases needs to be rebuilt using post-processing with the Maintenance Tools. The Thumbs and Similarity databases will need to be created from scratch, and the Face database includes the option Rebuild the Training Data.

Raccomandazioni sulla copia di sicurezza della banca dati

For security reasons, planning a database backup using crontab over the network can help against device failures. A NAS or an external drive can also be used for backup.

Each database can be renamed with a different, unique name. This allows users to backup only what is needed. For instance, renaming Core database as digiKam_Core, allows you to backup only this database, which is the most important file. Thumbnails, Similarity and Face Recognition databases can always be regenerated from scratch.

The chapter about digiKam Maintenance Tools will explain how to maintain the database contents and how to synchronize the collections with information in the databases (and vice versa).

Statistiche della banca dati

digiKam provides a unique tool to show the statistics from your collections. It includes count of images, videos (including individual count by image format), tags etc. this also includes the Database Backend (QSQLITE or QMYSQL) and the Database Path (where your collection is located).

Puoi visualizzare le tue statistiche dal menu Aiuto ‣ Statistiche della banca dati…. Apparirà un riquadro di dialogo tipo questo:

La Finestra di dialogo Statistiche della banca dati di digiKam