Need help to recreate data base


there are a few errors in my SQL data base, that keep me from upgrading to NC 17: missing ID and fields. I already tried to correct those errors for hours, but I did not succeed. Therefore, I decided that it might be easier and less time consuming to completely re-create a new data base and install NC 17 in one go.

What I want to do is to extract all the available data from MySQL, delete the hole data base, install NC 17 as new, create a new data base with correct values and data structure and re-import the data. Hopefully, the errors will be gone then…

I could need a little help with this. Could some one please give me a hand or provide some links where I can find instructions on how to do this without loosing my data?

My guess would be, after extracting the data and deleting the data base, I could follow any instruction on how to install NC 17 from scratch. But I am not sure about re-importing the data into the data base and the corrections that need to be done. Will theses errors really be gone after this procedure or will it turn out to be another waste of time?

if you want to install nc17 from scratch on a new server this might be helpful:

but only on a NEW server.

if the installation was successful you may try to import your old database and we could discuss this further.

1 Like

Thanks for that link.

I think I was not quite acurate when I mentioned installing NC 17 “from scratch”. I don’t think I really need to install from absolute zero, because nginx and mariadb are running fine. It’s just the db errors that keep bugging me. But those errors are not errors of the running mysql server, they are to be found inside the data base, some of its fields and indexes.

I guess my approach to solve these errors needs to look like this:

  • back up config.php and delete NC directory
  • extract NC 17 as /var/www/nextcloud
  • restore nextcloud/config/config.php

This is a simple upgrade, that I’ve done many times before. But here comes the part that I actually need help with:

  • extract and back up data from data base “nextcloud”
  • delete old data base
  • create new db with correct structure and permissions
  • import backed up data

Deleting the old db and creating a new one don’t pose a thread either, but I am not sure about backing up and restoring the data. How do I correctly extract every data I will need later and how do I need to import it without also importing the same mistakes as before? How do I make sure that the imported data will fit into the new db without causing the same errors as before?

I am not an expert in SQL and data bases. I know some basics, and I can follow instructions, and most of the times I even understand what is happening when I execute db commands. And I am also capable of doing a simple sql dump and restore. But my creativity fails me when I need to find a way to “repair” the data base and to get rid of these errors, so I can finally upgrade to NC 17.

I would always test this on a spare machine. (plan b, fallback) :wink:

mysqldump --single-transaction -h {{ nextcloud_db_host }} -u {{ nextcloud_db_user }} -p{{ nextcloud_db_passwd }} {{ nextcloud_db }} > nextcloud.dump

replace {{ … }} with your values.

DROP DATABASE nextcloud;

you have to edit the dump and remove the errors. and you have make sure that the db schema is converted from v16 to v17.

don’t know. you should post the errors. maybe someone will help you.

Thank you!

I will try this next week end.

(Of course: after doing a full back up! :slight_smile: )

Just to let you know: all went well, the new db is running and the warnings have gone! :smiley:

1 Like