Nextcloud
MariaDB Update 10.6 to 10.7
By jplee ~ Published – 2022/03/16
You want to manually update MariaDB 10.6 to 10.7. Therefore, follow the instructions from here: First of all, make sure that you have a valid Backup of the database. Such a backup, we start assuming now, with the Upgrade of MariaDB 10.6 to 10.7. To this end, we first stop the MariaDB 10.6 database server:
sudo -s
mysql -u root -p
SET GLOBAL innodb_fast_shutdown = 1;
XA RECOVER;
\q;
Stop the database server. Then backup the default configuration file by moving the file content to a backup file:
service mysql stop
mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
Uninstall all of the MariaDB Server packages. Note that a wildcard character is used to ensure that all MariaDB Server packages are uninstalled.
Be sure to check that this wildcard does not unintentionally refer to any of your custom applications.
apt remove "mariadb-*" "galera-*" Uninstall the Galera package as well. The name of the package depends on the specific version of MariaDB Server.
When upgrading from MariaDB Server 10.4, the package is called galera-4:
apt remove galera-4 When upgrading from MariaDB Server 10.3 or earlier, the package is called galera-3:
apt remove galera-3 Before proceeding, verify that all MariaDB Server packages are uninstalled. The following command should not return any results:
apt list --installed | grep -i -E "mariadb|galera" To be able to access the new database server version update, a new Repository is set up and the existing MariaDB 10.6 Source file renamed:
mv /etc/apt/sources.list.d/mariadb.list /etc/apt/sources.list.d/mariadb.list.10.6 To be able to receive version 10.7 update, we will set up a new MariaDB v10. 7 Source file:
apt install wget
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
echo "b9e90cde27affc2a44f9fc60e302ccfcacf71f4ae02071f30d570e6048c28597 mariadb_repo_setup" | sha256sum -c -
chmod +x mariadb_repo_setup
./mariadb_repo_setup --mariadb-server-version="mariadb-10.7"
apt update && apt upgrade -y Immediately following this, we install the new MariaDB 10.7 database server:
apt install -y mariadb-server mariadb-backup Update “my.cnf” default configuration file:
vim /etc/mysql/my.cnf You can copy all of the following lines into the empty file
[client]
default-character-set = utf8mb4
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
log_error=/var/log/mysql/mysql_error.log
nice = 0
socket = /var/run/mysqld/mysqld.sock
[mysqld]
basedir = /usr
bind-address = 127.0.0.1
binlog_format = ROW
bulk_insert_buffer_size = 16M
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
concurrent_insert = 2
connect_timeout = 5
datadir = /var/lib/mysql
default_storage_engine = InnoDB
expire_logs_days = 2
general_log_file = /var/log/mysql/mysql.log
general_log = 0
innodb_buffer_pool_size = 1024M
innodb_buffer_pool_instances = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 32M
innodb_max_dirty_pages_pct = 90
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 4000
innodb_flush_method = O_DIRECT
innodb_read_only_compressed=OFF
key_buffer_size = 128M
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
log_error = /var/log/mysql/mysql_error.log
log_slow_verbosity = query_plan
log_warnings = 2
long_query_time = 1
max_allowed_packet = 16M
max_binlog_size = 100M
max_connections = 200
max_heap_table_size = 64M
myisam_recover_options = BACKUP
myisam_sort_buffer_size = 512M
port = 3306
pid-file = /var/run/mysqld/mysqld.pid
query_cache_limit = 2M
query_cache_size = 64M
query_cache_type = 1
query_cache_min_res_unit = 2k
read_buffer_size = 2M
read_rnd_buffer_size = 1M
skip-external-locking
skip-name-resolve
slow_query_log_file = /var/log/mysql/mariadb-slow.log
slow-query-log = 1
socket = /var/run/mysqld/mysqld.sock
sort_buffer_size = 4M
table_open_cache = 400
thread_cache_size = 128
tmp_table_size = 64M
tmpdir = /tmp
transaction_isolation = READ-COMMITTED
#unix_socket=OFF
user = mysql
wait_timeout = 600
[mysqldump]
max_allowed_packet = 16M
quick
quote-names
[isamchk]
key_buffer = 16M
Save and close this file and then start the database server.
service mariadb start && mariadb-upgrade --force Verify The Above Transactions With The Following Command for Testing Purposes:
mysql -h localhost -uroot -p -e "SELECT @@TX_ISOLATION; SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA WHERE SCHEMA_NAME='nextcloud'" After the Start and Upgade to the existing database(s) you can use the System again fully available.
Create an update script file using Vim to optimize and update Nextcloud system:
vim update.sh Copy and paste below information into the new update.sh file:
# Ahuitech (February 17, 2022)
# Update script for Nextcloud 23.0.2.1 on ubuntu 20.04 system
#!/bin/bash
/usr/sbin/service nginx stop
sudo -u www-data php /var/www/nextcloud/updater/updater.phar
sudo -u www-data php /var/www/nextcloud/occ status
sudo -u www-data php /var/www/nextcloud/occ -V
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-primary-keys
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-columns
sudo -u www-data php /var/www/nextcloud/occ db:convert-filecache-bigint
sed -i "s/output_buffering=.*/output_buffering=0/" /var/www/nextcloud/.user.ini
chown -R www-data:www-data /var/nc_data /var/www
redis-cli -s /var/run/redis/redis-server.sock <<EOF
FLUSHALL
quit
EOF
sudo -u www-data php /var/www/nextcloud/occ user:list
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
sudo -u www-data php /var/www/nextcloud/occ files:scan-app-data
sudo -u www-data php /var/www/nextcloud/occ app:update --all
/usr/sbin/service php8.0-fpm restart
/usr/sbin/service nginx restart
exit 0
Save the update.sh file in Vim using the following commands:
Press the Esc key first and then type :wq and then press Enter key.
Now, execute the update.sh file with the following commands:
chmod +x update.sh
./update.sh
chmod -x update.sh
Congratulations, you now have your own personal data on your own secured Nextcloud system!
At Ahuitech, we create clouds systems that allow you to have complete control of your Data.
Ahuitech – Cloud Creations are always in your Control

