Edit by @Schmu: Careful! The following queries are not correct and may corrupt your database. Donāt use them! Rather use the queries by @Mauricedown below and only use them if you really cannot use the Nextcloud occ commands!
ALTER TABLE `oc_share` ADD KEY `owner_index` (`uid_owner`) USING BTREE;
ALTER TABLE `oc_share` ADD KEY `initiator_index` (`uid_initiator`) USING BTREE;
ALTER TABLE `oc_filecache` MODIFY `mtime` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `storage_mtime` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `fileid` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `storage` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `parent` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `mimetype` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `mimepart` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_activity` MODIFY `activity_id` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_activity` MODIFY `object_id` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_activity_mq` MODIFY `mail_id` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_mimetypes` MODIFY `id` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_storages` MODIFY `numeric_id` bigint NOT NULL DEFAULT '0';
I updated my DB with the lines from @ffs69 and all works fineā¦
BUT After update my DB with the code from @bettsr down the line āfileIDā i get now a āInternal Server Errorā !!!
OOOHHH F****
And in the nextcloud.log File the entries explode with the following values {āreqIdā:āXB4f3@3JfHdDuVtupSp21gAAABMā,ālevelā:3,ātimeā:ā2018-12-22T11:28:31+00:00ā,āremoteAddrā:ā217.231.174.201ā,āuserā:āWebmasterā,āappā:āindexā,āmethodā:āGETā,āurlā:"/index.php/apps/theming/styles?v=9",āmessageā:{āExceptionā:āRuntimeExceptionā,āMessageā:āFile entry could not be inserted but could also not be selected with getId() in order to perform an update. Please try again.ā,āCodeā:0,āTraceā:[{āfileā:"/www/htdocs/xxxx/nextcloud/lib/private/Files/Cache/Cache.php",ālineā:232,āfunctionā:āinsertā,āclassā:āOC\Files\Cache\Cacheā,ātypeā:"->",āargsā:[āappdata_ocw0h5ldt441/css/theming/ca9f-aecb-theming.css.depsā,{āmimetypeā:āapplication/octet-streamā,āmtimeā:1545476254,āsizeā:0,āetagā:ā18df4e41056878e105ef482d40afd805ā,āstorage_mtimeā:1545476254,āpermissionsā:27,āparentā:211,āchecksumā:"",āpathā:āappdata_ocw0h5ldt441/css/theming/ca9f-aecb-theming.css.depsā,ānameā:āca9f-aecb-theming.css.depsā}]},ā¦
ALTER TABLE `oc_filecache` MODIFY `fileid` bigint NOT NULL AUTO_INCREMENT;
ALTER TABLE `oc_filecache` MODIFY `storage` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `parent` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `mimetype` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `mimepart` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `mtime` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_filecache` MODIFY `storage_mtime` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_activity` MODIFY `activity_id` bigint NOT NULL AUTO_INCREMENT;
ALTER TABLE `oc_activity` MODIFY `object_id` bigint NOT NULL DEFAULT '0';
ALTER TABLE `oc_activity_mq` MODIFY `mail_id` bigint NOT NULL AUTO_INCREMENT;
ALTER TABLE `oc_storages` MODIFY `numeric_id` bigint NOT NULL AUTO_INCREMENT;
I also used the lines from bettsr and nextcloud didnāt work anymore.
I tried you suggestion but phpmyadmin gave the following error:
Error
SQL query:
ALTER TABLE `oc_filecache` MODIFY `fileid` bigint NOT NULL AUTO_INCREMENT
MySQL said: Documentation
#1062 - ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
Well this is bad, sorry to hear that. We really need to take our time and check everything, before we suggest or make any changes to our databases. We can really mess things up.
This is actually a job for a database expert then or you take your time and read into this issue a bit more. I hope you have a backup of your database already.
I suggest you set your NC server in maintenance until this DB issue is fixed. When you set your server in maintenance create an additional backup right afterwards ā¦ before you perform any new changes.
I searched the net a bit and this here seem to be the best suggestions to solve your issue:
Pick one of the two highest voted solutions and try them. Personally Iād pick the answer with 31 upvotes first.
But perform some select statements before and get an idea of the tables content first. Is there an entry with fileid=0? Are there more than one entries with fileid=0 which need to be manually fixed afterwards?
By the way:
I read a post here in the forum, where a user of a hosted NC server mentioned the ability to configure cron jobs via the web gui (of his provider). He used this option to configure occ as cron job for a few minutes in the future, waited until the command ran and removed the cron job again.
Just mentioning this in case you have this option too and want to avoid messing with the DB manually next time.
The line you quoted, doesnāt contain any database name.
You can connect to the correct database for example during login already: mysql -u myname -p <DATABASENAME>
Or can also connect to the database after your current way to login: connect <DATABASENAME>
and then run the āalter tableā query.
Example:
> mysql -u oc_ncadmin -p
mysql> connect nextcloud_db
mysql> ALTER TABLE oc_filecache MODIFY mtime bigint NOT NULL DEFAULT '0';
MariaDB [(none)]> connect nextcloud
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Connection id: 4084
Current database: nextcloud
MariaDB [nextcloud]> ALTER TABLE oc_filecache MODIFY mtime bigint NOT NULL DEFAULT ā0ā;
ERROR 1054 (42S22): Unknown column āā0āā in āDEFAULTā
MariaDB [nextcloud]>
It feels a bit risky running database commands that might result in a broken database and thus taking down my nextcloud server. My manual installation of nextcloud in fedora 29 is working well at the moment. I think it would be much safer if i create another database to test it out. What is the unknown column?
The problem that i am trying to solve:
Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running āocc db:convert-filecache-bigintā those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read the documentation page about this.
Definitely true. If you have the chance to use the occ commands, use that instead of running mysql queries.
I believe the unknown column error is caused by a copy and paste issue. With copy and pasting ā0ā you might get different characters than actually single ticks '0'
Because actually the column which is intended to be changed here is mtime.
As suggested use occ command rather, if possible, run the occ web app (https://apps.nextcloud.com/apps/occweb) or try to copy the command from here: ALTER TABLE oc_filecache MODIFY mtime bigint NOT NULL DEFAULT '0';
Change directory and run nextcloud database conversion to big int:
[root@pc jonathon]# cd /var/www/html/nextcloud/
[root@pc nextcloud]# sudo -u apache php occ db:convert-filecache-bigint
The current PHP memory limit is below the recommended value of 512MB.
Following columns will be updated:
filecache.mtime
filecache.storage_mtime
This can take up to hours, depending on the number of files in your instance!
Continue with the conversion (y/n)? [n] y
ALTER TABLE oc_filecache
ALTER COLUMN mtime SET DATA TYPE bigint,
ALTER COLUMN storage_mtime SET DATA TYPE bigint;
CREATE INDEX initiator_index ON oc_share USING btree (uid_initiator);
CREATE INDEX owner_index ON oc_share USING btree (uid_owner);
Hello everybody,
First of all I wish you all very happy celebrations!
I turn to you regarding the new alerts in my configuration since the update from 17.0.1 to 17.0.2:
āSome columns in the database are missing a conversion to big int. [ā¦]ā
mounts.storage_id
mounts.root_id
mounts.mount_id
I donāt know how to identify the characteristics to make the necessary sql commands myself, if someone can help me?
I know it should look something like this:
ALTER TABLE `???` MODIFY `mounts.storage_id` bigint ???;
ALTER TABLE `???` MODIFY `mounts.root_id` bigint ???;
ALTER TABLE `???` MODIFY `mounts.mount_id` bigint ???;
But I donāt know how to identify in which table (oc_filecache, oc_mimetypes, oc_storages, ā¦) and what value to configure for each column (NOT NULL DEFAULT ā0ā or NOT NULL AUTO_INCREMENT)?
In advance thank you for your help and all wishes of happiness and good health to all