Migrating SQLite database to MySQL


Following an installation tutorial, I am greeted on the NC interface with a warning that I am using a SQLite database. Having created the database through MariaDB I thought it would already be with MySQL…
Before going any further, I’d like to convert the database to MySQL.

I’ve identified the missing database connector as instructed by the NC Linux installation guide. “You can check the presence of a module by typing php -m | grep -i <module_name> . If you get a result, the module is present.”

Database connectors (pick the one for your database:)

1-PHP module pdo_sqlite (>= 3, usually not recommended for performance reasons)
2-PHP module pdo_mysql (MySQL/MariaDB) 
3-PHP module pdo_pgsql (requires PostgreSQL >= 9.0)

I get a result for 1 but not 2 & 3, so I’m understanding that using MariaDB for the database creation doesn’t mean I’m using MySQL…

Nextcloud version 18.0.0
Operating system and version Raspbian GNU/Linux 10 (Buster)
Apache 2.4.38
PHP version 7.3.11

Is this the first time you’ve seen this error? Yes

Steps to replicate it: https://pimylifeup.com/raspberry-pi-nextcloud-server/

Any guidance would be appreciated, I am pretty new at this but eager to learn and understand!

you can convert from sqlite to mysql:


and i think you have to install the php-mysql module.

sudo apt install php7.3-mysql

Thanks for the link. Added the php7.3-mysql.

Trying to get this command right “php occ db:convert-type --all-apps mysql oc_mysql_user new_db_name”

I created another database in the NC root folder named “data2” and when prompting the new command “sudo -u www-data php occ db:convert-type --all-apps --password=“XXX” mysql nextcloud localhost data2” I get “Could not open input file: occ”

I think my permissions might be off, they look like this at the moment.

m@rpi4:/var/www/html $ ls -lh
total 102M
-rw-r–r-- 1 www-data root 11K Jan 23 23:06 index.html
drwxr-x— 15 www-data www-data 4.0K Jan 27 19:09 nextcloud
-rw-r–r-- 1 www-data root 102M Jan 17 08:52 nextcloud-18.0.0.zip
-rw-r–r-- 1 www-data root 55 Jan 17 08:52 nextcloud-18.0.0.zip.md5
-rw-r–r-- 1 root root 0 Jan 25 13:27 test.php

In which folder do you start the command?
Be sure to
cd /var/www/html/nextcloud
before using occ

1 Like

or try:

sudo -u www-data php /var/www/html/nextcloud/occ db:convert-type --all-apps --password=“XXX” mysql nextcloud localhost data2

Thanks for the answers, I have tried those commands within the nextcloud folder after changing directory permissions and I’m getting this response.

"Nextcloud is not installed - only a limited number of commands are available

There are no commands defined in the “db” namespace."

As stated in my first post, I stopped at the first greeting page of NC asking to create an admin account, thinking it would be easier to modify the database before going further.

Is it easier to complete the admin creation and transform the database or can someone explain how to create the initial database with MariaDB/MySQL but not SQLite?

sudo mysql -uroot -p

CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; 
CREATE USER nextcloud@localhost identified by 'secret-password'; 
GRANT ALL PRIVILEGES on nextcloud.* to nextcloud@localhost; 
FLUSH privileges; 

change the secret-password to something secret.

and read the docs: https://docs.nextcloud.com/server/18/admin_manual/configuration_database/linux_database_configuration.html?highlight=mysql#configuring-a-mysql-or-mariadb-database to setup the database before.


That did it, very grateful for the help. The satisfaction when everything works out is worth the time!