How to enable the 4-byte support Mariadb 10.5

Hello, i have under Nextcloud 22 the follwing warning and i search a easy tutorial how to do that:

MySQL is used as database but does not support 4-byte characters. To be able to handle 4-byte characters (like emojis) without issues in filenames or comments for example it is recommended to enable the 4-byte support

I know myphpadmin and i can some things do with putty - but the original manual is at the moment to difficult for me - and i have fear, to crash the database.

Hi @stefan-franz

I don’t know myphpadmin but it is probably easier doing it all from the command line. You only have to pass one statement to the database. The rest like changing the MariaDB config and the Nextcloud OCC commands you have do via command line anyways…

Thats how I would do it:

Login to your server using PUTTY and backup your MariaDB configuration file:

sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup

Then open the configuration file with nano:

sudo nano /etc/mysql/my.cnf

Look for the section [mysqld]

and make sure it contains the following line:

innodb_file_per_table = 1

If the line is already there but with another value, change the value to 1, if it is not there or commented out, just add the line. After that save the file by pressing CTRL + O and exit nano by pressing CTRL + X.

Back in the command line, restart the MariaDB service:

sudo systemctl restart mariadb

Then change into your Nextcloud installation directory…

cd /path/to/Nextcloud

…and put Nextcloud into maintanance mode:

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

Then login to your MariaDB as root…

mysql -u root -p

…and enter the following statement:

ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

exit the database with:

exit;

Back in the Linux command line, enter the following commands:

sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
sudo -u www-data php occ maintenance:repair

Disable maintanance mode:

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

Done. :slight_smile:

Puh…is not easier…i think i don’t here something…i fear to crash my server.
Thanks for your help.

No it’s not and it is also no longer valid… (see my previous post.)

Thank you, i have deleted the link.

I think it looks much more complicated then it actually is… At least not more complicated then installing Nextcloud in the first place…

If you follow the steps I posted carefully one by one, there is no way how you could crash your database. These steps are from the official documentation. I just added a few more things that were left out in the docs because they probably assume that you know these things. Chances of doing something wrong in MyPHPadmin are way higher, if you do not know exactley what you are doing. And you would still have to change the configiuration parameter and execute the occ command via command line :wink:

Ok - i will try it. One question:
If i shoot the database down…if i restore a backup all would run again, right?

There comes that error.

sudo -u www-data php occ maintenance:mode --on
This version of Nextcloud requires at least PHP 7.3
You are currently running 7.2.24-0ubuntu0.18.04.10. Please update your PHP version

But i have installed php 8.0.13 - and in nextcloud / admin / system it is shown that it works with 8.0.13

I stop now because maintanance mode on doesn’t work - nextcloud ist still running.

How can i solve this problem?

It looks like you have both PHP versions installed on your system and on the command line it defaults to 7.2. You can try to specify PHP 8.0 in the command like this…

sudo -u www-data /usr/bin/php8.0 occ maintenance:mode --on

i’m standing in the nextcloud directory…

sudo -u www-data /usr/bin/php8.0 occ maintenance:mode --on
sudo: /usr/bin/php8.0: Befehl nicht gefunden

i think, the best is, i update first the php version that is taken from the text console

If Nextcloud says that it’s using PHP 8.0 you have at least some PHP 8.0 packages installed, but you probably didn’t install the php8.0-cli package. You can install it with sudo apt install php8.0-cli and then try again.

I use Plesk and ubunto 18.04 - i installed it under plesk. I think i need the cli version as your tip.
But that doesn’t work

E: Paket php8.0-cli kann nicht gefunden werden.
E: Mittels des Musters »php8.0-cli« konnte kein Paket gefunden werden.
E: Mittels regulärem Ausdruck »php8.0-cli« konnte kein Paket gefunden werden.

Sorry I don’t know Plesk. But I found this…

https://docs.plesk.com/de-DE/obsidian/administrator-guide/webhosting/php-management/ausführen-von-phpskripts-über-die-befehlszeile.76345/

The path to the executable seems to be diffrent when it is installed by Plesk…

Try… sudo -u www-data /opt/plesk/php/8.0/bin/php occ maintenance:mode --on

Very thank you for your help

root@h2937523:/var/www/vhosts/sxxxxxxxxe/nextcloud# sudo -u www-data /opt/plesk/php/8.0/bin/php occ maintenance:mode --on
Cannot write into “config” directory!
This can usually be fixed by giving the webserver write access to the config directory.

But, if you prefer to keep config.php file read only, set the option “config_is_read_only” to true in it.
See https://docs.nextcloud.com/server/22/go.php?to=admin-config

Now, i finish for today…i think i first update the php at cli and ask in the plesk forum how to do.

Thank you very much for your help.

php 8.0 is installed. On this step that appears

MariaDB [(none)]> ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ERROR 1 (HY000): Can’t create/write to file ‘./nextcloud/db.opt’ (Errcode: 2 “No such file or directory”)
MariaDB [(none)]>

Hmm Not sure why that is…

Are you sure the name of your database is actually “nextcloud”?

I did a quick google search and found this…

Maybe the sql-statement isn’t needed on version 10.5 and you could just try to execute the ooc
config:system:set and occ repair commands…

Ah - instead of

ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
i have to replace the word database with the real name of the database
e.g my database name would be nextcloud_1234bde
the correct command would be: right?
ALTER DATABASE nextcloud_1234bde CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

And one note:
sudo -u www-data php occ maintenance:mode --on
is not working - because the config.php is is locket (from plesk oder nextcloud)
I was able to edit the config in the plesk browser and switched ‘maintenance’ => true,

My question: If this config is blocked, do the next commands working?

Afaik they do not write anything to the config .php, so they should work. But to be a 100% sure you could set 'config_is_read_only' => false, in your config.php. You can change it back to true, after you finished the conversion. Whether Plesk also has an impact on this, I don’t know. As I said, I’m not familiar with it at all