Change from SQLite to MySQL

Hello all,

I have just installed owncloud server and at the end of the instalation process, I didn’t realise I could change the db parameter. Now the owncloud server is runing with SQLite. Is there a way to go back in the instalation process. I have nothing on my owncloud server yet and I have configured the MySQL parameters.

Can I just change the config.php ‘dbtype’ => ‘sqlite3’, to ‘mysql’ ???

Thanks for your help!!!


Hi Edwin,

you could just run another installation with mysql database configured. If you don't have any data on your server.

You could make an installation followin the manual . I assume you have the latest owncloud version installed.

Or you could convert your database to mysql - with this guide

Thanks Dmitry,

I have re-installed owncloud and now it says this, when I go to localhost/owncloud/...

"This ownCloud instance is currently in maintenance mode, which may take a while.
This page will refresh itself when the ownCloud instance is available again.
Contact your system administrator if this message persists or appeared unexpectedly.
Thank you for your patience."

Don't know what to do.

Do you have access to the command line?

if yes, switch to your owncloud dir for example

cd /var/www/owncloud

and then do

sudo -u www-data php occ maintenance:mode --off

OK I did this. And Owncloud works again. But it hasn't asked me to configure the database this time. So I assume it still uses sqlite.

Moreover, when I open (sudo nano) the config.php files, it says it being edited by root and it appears empty!!!

What should I do???

usually if you are root and want to open a file that is open by root, you can just continue editing

With your second setup, did you configure your database?

No, I did not configure the database. With the reinstall, I just enter my credentials and all was set up. What I wanted is use mysql and not sqlite...

Any ideas?

You are installing using repositories, right?

Yes I do!!!


If yes, you would have to set up a mysql database, for that you would need to install a mysql server, then create a database for owncloud, and then run the occ command to convert from sql lite to mysql

php occ db:convert-type --all-apps mysql oc_mysql_user new_db_name

all that you can find in my first post :slight_smile:

to get mysql just run this commands

apt install -y apache2 mariadb-server libapache2-mod-php7.0 \
    php7.0-gd php7.0-json php7.0-mysql php7.0-curl \
    php7.0-intl php7.0-mcrypt php-imagick \
    php7.0-zip php7.0-xml php7.0-mbstring

aside from the database, that is in the configuration section of the manual

mysql -uroot -p

GRANT ALL PRIVILEGES ON owncloud.* TO 'username'@'localhost' IDENTIFIED BY 'password';


Ok, after consulting I have something for you .

You have installed owncloud, right? As final step you would to to the ip address and finish the installation. But if you want to use mysql, you can install the mariadb-server and php.7.0-mysql modules, then log in to the db-server, create a db, with user and password, then go to the ip for example localhost/owncloud, choose the mysql database instead of sql lite, enter the credentials, and then you will have a mysql database with owncloud

Since this is a fresh installation there is no need to use db:convert-type. Re-installation is the way to go.

When you convert the database from SQLITE to MYSQL, do you need to be in any specific directory, or can you just run the command from anywhere? Also, will it only convert the specific database for OwnCloud and leave other databases associated with other applications alone alone? Final point, does it automatically update the config.php file to reflect the new database? Currently my config.php file is showing me that OwnCloud is using SQLITE3 as a database.
I take your point DeepDiver1975, but to be honest, when I started out I thought along the lines you mention, and what started out as a test installation has grown into something a bit more sophisticated. :wink:

From what i know / have read the migration from sqlite to mysql currently doesn’t work at all in ownCloud 10.

Ok, so why do we include the procedure in the manual? :thinking:
Surely it would be easier to simply state that it is not currently possible to perform this function, and so set up your installation using Lite or Full MSQL from the start.
Personally, I think the continued use of SQLite is a pain in the butt.