# Migrate users to new install

**URL:** <https://help.nextcloud.com/t/migrate-users-to-new-install/66161>\
**Category:** ℹ️ Support\
**Created:** [December 13, 2019, 12:47pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161 "2019-12-13T12:47:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjoldman](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mjoldman/32/16264_2.png) [@mjoldman](https://help.nextcloud.com/u/mjoldman)\
**Post date:** [December 13, 2019, 12:47pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/1 "2019-12-13T12:47:34Z")

</div>

Is there a way to migrate users to a new install?

I have an existing nextcloud installation which will refuses to update. I need to move this to a new server and wish to migrate the 30+ users and passwords that I have already to a fresh install.

I don’t need to migrate any files - users can only view files shared by admins and are configured to not be able to upload their own.

Old server is running version 13.01  
New server is running 17.01

I have tried importing the following tables which seem to contain user related info  
oc\_users  
oc\_addressbooks  
oc\_accounts  
oc\_groups  
oc\_group\_admin  
oc\_group\_user

Unfortunately this generates a server error and I cant log in with either an admin or user account.

Any ideas?  
Is this possible?

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [December 16, 2019, 12:42pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/2 "2019-12-16T12:42:51Z")

</div>

I believe you need to set a new server with 13.01, restore your DB from initial Server and do all major versions update till 17…

---

<div class="post-metadata">

**Author:** ![mjoldman](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mjoldman/32/16264_2.png) [@mjoldman](https://help.nextcloud.com/u/mjoldman)\
**Post date:** [December 18, 2019, 11:59pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/3 "2019-12-18T23:59:44Z")

</div>

Thanks - this was indeed way to do it.  
For others benefit who may want to do the same:

- used web installer (with modified setup-nextcloud.php. ) to install of old version.  
Needed to change setup-nextcloud.php replacing // Nextcloud version define(‘NC\_VERSION’, ‘17.0.1’); with // Nextcloud version define(‘NC\_VERSION’, ‘13.0.1’);
- Dropped following tables in phpmyadmin and installed copies from old server  
oc\_users  
oc\_addressbooks  
oc\_accounts  
oc\_groups  
oc\_group\_admin  
oc\_group\_user
- Incremental in app update of all Nextcloud versions through to 17.0.1

Worked perfectly - all user details and groups preserved

---

<div class="post-metadata">

**Author:** ![Jobass44](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jobass44/32/19997_2.png) [@Jobass44](https://help.nextcloud.com/u/Jobass44)\
**Post date:** [December 28, 2019, 1:59pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/4 "2019-12-28T13:59:25Z")

</div>

Hello from France. Thanks for this thread, that is exactly what i’m looking for. I need to migrate too the users from one serveur to another with a new instance. The old one is 17 and the one new too obviously. Both are up to date, nonetheless, the old one is a “classique” architecture with mysql and phpmyadmin, and the new one is built with Docker (and docker-compose) and mariadb with containers, for increased performance and easiest maintenance. My questions :

- any incompatibilty between mysql and mariadb tables to migrate these users tables ? I don’t think so but not sure…
- could you please show me what commands and synthax you used for that operation ? I guess it is DROP TABLE for each one to export… Then what to do ? The commands create a file ?? I take this file to put it where ? How can I can do the import on my mariadb container then ?

I precise my mariadb container has an external folder, on the host (Ubuntu serveur). I suppose i put the files here and within the container with docker exec i import them ? What commands ?

Thanks a lot for your replies and your lights which will help many of us I think.

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [January 13, 2020, 10:52am UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/5 "2020-01-13T10:52:46Z")

</div>

> [@Jobass44](#):
>
> any incompatibilty between mysql and mariadb tables to migrate these users tables ? I don’t think so but not sure…

Check this out, it seems nothing to change, only please check mySQL and MariaDB Versions: [Migration from MySQL to MariaDB](https://help.nextcloud.com/t/migration-from-mysql-to-mariadb/6816)

> [@Jobass44](#):
>
> could you please show me what commands and synthax you used for that operation ? I guess it is DROP TABLE for each one to export… Then what to do ? The commands create a file ?? I take this file to put it where ? How can I can do the import on my mariadb container then ?

🙂 do not think so, you can [backup](https://docs.nextcloud.com/server/17/admin_manual/maintenance/backup.html#mysql-mariadb) and [restore](https://docs.nextcloud.com/server/17/admin_manual/maintenance/restore.html#mysql) you DB in a new server, especially if you have only those 2 users. Please read whole docu there.

---

<div class="post-metadata">

**Author:** ![Jobass44](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jobass44/32/19997_2.png) [@Jobass44](https://help.nextcloud.com/u/Jobass44)\
**Post date:** [January 16, 2020, 4:18pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/6 "2020-01-16T16:18:40Z")

</div>

Thanks for your advices.  
I figured it out.

Connect to mysql : mysql -u root -p nextcloud  
netxcloud -\> name of your nextcloud instance (nextcloud in my case)

Commands for dumps (export) :

mysqldump -u root -p nextcloud oc\_users \> /mnt/oc\_users.sql;  
mysqldump -u root -p nextcloud oc\_addressbooks \> /mnt/oc\_addressbooks.sql;  
mysqldump -u root -p nextcloud oc\_accounts \> /mnt/oc\_accounts.sql;  
mysqldump -u root -p nextcloud oc\_groups \> /mnt/oc\_groups.sql;  
mysqldump -u root -p nextcloud oc\_group\_admin \> /mnt/oc\_group\_admin.sql;  
mysqldump -u root -p nextcloud oc\_group\_user \> /mnt/oc\_group\_user.sql;

It will create .sql files in /mnt/ (you can choose any folder on the host, it’s your choice).

Copy those file in your new server in /mnt/ (on the host).  
I transfer the files from one to the other via WinSCP.

Commands for the import (via docker-compose) :

docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud \< /mnt/oc\_users.sql  
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud \< /mnt/oc\_addressbooks.sql  
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud \< /mnt/oc\_accounts.sql  
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud \< /mnt/oc\_groups.sql  
docker-compose exec -T db mysql -unextcloud -pXXXXXXXXnextcloud \< /mnt/oc\_group\_admin.sql  
docker-compose exec -T db mysql -unextcloud -pXXXXXXXX nextcloud \< /mnt/oc\_group\_user.sql

db = service name in docker-compose  
-unextcloud = user  
-pXXXXXXXX = pass  
nextcloud = name of the instance

In docker-compose, it matches with the env variables :

- MYSQL\_PASSWORD=
- MYSQL\_DATABASE=
- MYSQL\_USER=

After that, it’s done.  
Go in Web-app, all the users account are here and safe, with passwords. No problem to connect with these accounts.

Except one thing. The e-mails are not there.  
I’ve found that these users accounts e-mails are in oc\_preferences table.  
But my dump with that table creates an empty file. Never found why…  
Nevermind, I’ve done this manually.

I don’t know how mjoldman had success with e-mails because, they are in oc\_preferences table.  
It was a detail for me, so nevermind.

No incompatibility between export mysql and import mariadb in my case.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 12:25pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/7 "2024-12-04T12:25:39Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 11, 2024, 4:08pm UTC](https://help.nextcloud.com/t/migrate-users-to-new-install/66161/8 "2024-12-11T16:08:54Z")

</div>


