Mariadb server 10.6

Hi Almalinux specialists and users.

In an attempt to upgrade my mariadb from 10.3 to 10.6 I fell in a locked position.
I followed a manual that told me to copy my /var/lib/mysql/ to a backup location, which I did. After I removed MariaDB-server and MariaDB-client from the system . I upgraded the repository on almalinux for mariadb 10.6 And i reinstalled by : sudo dnf install MariaDB-server MariaDB-client . It found 10.6 and after that installation seemed normal.

Now, I know there are much better mariadb dump database commands to do this kind of thing now. Just I found the right manuals too late.
I executed this as a dump:
sudo mysqldump -u root -p --all-databases > /path/all-database-backup.sql
I don’t know if this command do mysql and mariadb databases in one file.
Besides that file I have only a hard copy of my old 10.3 database folder.

When I start mariadb after installation, it runs, however, trying to copy back my old /var/lib/mysql/ back to the new installation’s path (/var/lib/mysql/), all hell broke loose.
Whatever I do or try the server will not start up.

I started by checking all the permissions and ownership of var/lib/mysql/
(after hard copying the backup back to /var/lib/mysql/ )

sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod -R 0755 /var/lib/mysql

And I tried commands like :
sudo mysql_upgrade -u root -p

Attempts to start mariadb or use the upgrade command above all end up in this kind of error:

$ sudo mariadb-upgrade -u root -p
Enter password:
Reading datadir from the MariaDB server failed. Got the following error when executing the ‘mysql’ command line client
ERROR 2002 (HY000): Can’t connect to local server through socket ‘/var/lib/mysql/mysql.sock’ (111)

I tracked for some hours to resolve this issue and save my databases. No luck, all manuals refer to permission and ownership.
Searching on: Can’t connect to local server through socket ‘/var/lib/mysql/mysql.sock’ (111)

Give me advice to delete log files like:
sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1

which should solve the problem. Doesn’t work.

I think the database is corrupt. cause the new version of mariadb can’t cope with the older databases i have for 10.3 But since I can’t use the mariadb-upgrade command,
I am not able to convert the databases to 10.6 format. Correct me if I am wrong.

Does anybody how to resolve this situation? I can’t go back to 10.3 cause I need 10.6 for an new application that is depending on 10.6
So I was forced to upgrade it, where the problem started. 10.3 was running fine.
Thanks in advance for any tips…

Dirk.

Hi,
if you use SELinux in Enforcing mode on your system check that it is not SELinux that is preventing you to connect to your local server through socket?

Check your SELinux status with this command (as root or sudo):

sestatus

I get this, because I run SELinux in Enforcing mode:

SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      33

And what do you get if you run the command (as root or sudo):

ls -alZ /var/lib/mysql

For the file mysql.sock you should get something similar to this:

srwxrwxrwx.  1 mysql mysql system_u:object_r:mysqld_db_t:s0             0 Mar 10 16:43 mysql.sock

Just today I have upgraded MariaDB 10.6.x to 10.11.x without any problems on my ALMA 9 system.

Best regards,
OMMB

Sorry, for replying late. I didn’t receive the notice someone answered on the topic. Thank you for your help.

Selinux:

$ sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: permissive
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 33

sudo ls -alZ /var/lib/mysql mysql

drwxr-xr-x. 6 mysql mysql system_u:object_r:mysqld_db_t:s0 4096 8. Mär 17:08 .
drwxr-xr-x. 80 root root system_u:object_r:var_lib_t:s0 4096 8. Mär 17:03 …
-rw-rw----. 1 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 417792 8. Mär 17:04 aria_log.00000001
-rw-rw----. 1 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 52 8. Mär 17:04 aria_log_control
-rw-rw----. 1 mysql mysql system_u:object_r:mysqld_db_t:s0 9 8. Mär 17:08 ddl_recovery.log
-rw-rw----. 1 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 906 8. Mär 17:04 ib_buffer_pool
-rw-rw----. 1 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 12582912 8. Mär 17:04 ibdata1
-rw-rw----. 1 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 100663296 8. Mär 17:08 ib_logfile0
-rw-rw----. 1 mysql mysql system_u:object_r:mysqld_db_t:s0 12582912 8. Mär 17:08 ibtmp1
-rw-rw----. 1 mysql mysql system_u:object_r:mysqld_db_t:s0 8 8. Mär 17:08 leeuwserver.pid
-rw-rw----. 1 mysql mysql system_u:object_r:mysqld_db_t:s0 0 8. Mär 17:08 multi-master.info
drwx------. 2 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 4096 8. Mär 17:04 mysql
srwxrwxrwx. 1 mysql mysql system_u:object_r:mysqld_db_t:s0 0 8. Mär 17:08 mysql.sock
-rw-r–r–. 1 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 15 8. Mär 17:04 mysql_upgrade_info
drwx------. 2 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 4096 8. Mär 17:04 performance_schema
drwx------. 2 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 12288 8. Mär 17:04 sys
drwx------. 2 mysql mysql unconfined_u:object_r:mysqld_db_t:s0 4096 8. Mär 17:04 test

what does it mean? As far i can see, the list has all permission for the owner, and the owner is mysql. Is there any reason why it shouldn’t work?
Is there anything else to try and find the bottleneck…?

Could you give me your procedure and command list to upgrade to another version?
(What you said you did that day.)

Thanks!

Dear leeuw,
it seems that you are running SELinux in Permissive mode, so SELinux should not be the cause of the problem!

If the command sudo ls -alZ /var/lib/mysql gives you the entire contents of the directory as you wrote then I think that all the directories/files of your databases (from MariaDB 10.3) are missing. As I can see there is a standard file/directory structure as when you install MariaDB server for the first time. No other directories that holds your databases from MariaDB 10.3 are present.

I would start from the beginning:
Upgrade to MariaDB Community Server 10.6

Later:
I managed to reinstall the server and to start it . As long as I do not attempt to cop y back anything of the old directory with databases (/var/lib/mysql) I can login and give commands to SQL databases. If I would like to copy back my old databases, what is the best way to do it without corrupting my fresh installation?

update:

I couldn’r resist and tried this after last update:


the manual:

A MySQL MyISAM table is the combination of three files:

  • The FRM file is the table definition.
  • The MYD file is where the actual data is stored.
  • The MYI file is where the indexes created on the table are stored.

You should be able to restore by copying them in your database folder (In linux, the default location is /var/lib/mysql/)

You should do it while the server is not running.


AND I did this:

Step 1. Shutdown Mysql server

Step 2. Copy database in your database folder (in linux, the default location is /var/lib/mysql). Keep same name of the database, and same name of database in mysql mode.

sudo cp -rf   /mnt/ubuntu_426/var/lib/mysql/database1 /var/lib/mysql/

Step 3: Change own and change mode the folder:

sudo chown -R mysql:mysql /var/lib/mysql/database1
sudo chmod -R 660 /var/lib/mysql/database1
sudo chown  mysql:mysql /var/lib/mysql/database1 
sudo chmod 700 /var/lib/mysql/database1

Step 4: Copy ibdata1 in your database folder

sudo cp /mnt/ubuntu_426/var/lib/mysql/ibdata1 /var/lib/mysql/

sudo chown mysql:mysql /var/lib/mysql/ibdata1

Step 5: copy ib_logfile0 and ib_logfile1 files in your database folder.

sudo cp /mnt/ubuntu_426/var/lib/mysql/ib_logfile0 /var/lib/mysql/

sudo cp /mnt/ubuntu_426/var/lib/mysql/ib_logfile1 /var/lib/mysql/

Remember change own and change root of those files:

sudo chown -R mysql:mysql /var/lib/mysql/ib_logfile0

sudo chown -R mysql:mysql /var/lib/mysql/ib_logfile1

or

sudo chown -R mysql:mysql /var/lib/mysql

Step 6 (Optional): My site has configuration to store files in a specific location, then I copy those to corresponding location, exactly.

Step 7: Start your Mysql server. Everything come back and enjoy it.

That is it. (end)


I couldn’t start the server after doing that and I systemctl status gave:

● mariadb.service - MariaDB 10.6.21 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: failed (Result: exit-code) since Sun 2025-03-16 22:45:50 CET; 40s ago
Docs: man:mariadbd(8)
systemd - MariaDB Knowledge Base
Process: 2485724 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 2485711 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ]>
Process: 2485709 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 2485724 (code=exited, status=1/FAILURE)
Status: “MariaDB server is down”

Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [Note] InnoDB: Retry with innodb_force_recovery=5
Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [ERROR] InnoDB: Plugin initialization aborted with error Data str>
Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [Note] InnoDB: Starting shutdown…
Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [Note] Plugin ‘FEEDBACK’ is disabled.
Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [ERROR] Unknown/unsupported storage engine: InnoDB
Mär 16 22:45:50 server mariadbd[2485724]: 2025-03-16 22:45:50 0 [ERROR] Aborting
Mär 16 22:45:50 server systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Mär 16 22:45:50 server systemd[1]: mariadb.service: Failed with result ‘exit-code’.
Mär 16 22:45:50 server systemd[1]: Failed to start MariaDB 10.6.21 database server.


And after that I tried: sudo mariadb-upgrade -u root -p

which resulted again in :

sudo mariadb-upgrade -u root -p
Enter password:
Reading datadir from the MariaDB server failed. Got the following error when executing the ‘mysql’ command line client
ERROR 2002 (HY000): Can’t connect to local server through socket ‘/var/lib/mysql/mysql.sock’ (2)
FATAL ERROR: Upgrade failed


So, I ended up again with the same. Now i can reinstall mariadb again and try again…
What is my mistake?

Dear leeuw,
if you still have the old server with MariaDB 10.3 I would start from the beginning from the old server as it is written on the link that I posted in my previous message.

Be careful especially when doing the
1.Take a full backup.
2.The backup must be prepared.

As you can see you have to prepare the old databases before you move the data to the new server. Follow the instructions carefully as it is written there!

Best regards,
OMMB