failed to start mariadb 10.5 on Rocky Linux 8.9

so this is my first post in 2024, probably would write again regularly.

today i try to install mariadb 10.5 on rocky linux 8.9 and it is sucessfully installed but it failed to start.

this is the error message from systemctl status:

# systemctl status mysqld
? mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2024-01-03 17:10:09 WIB; 6min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 807 ExecStart=/usr/libexec/mysqld --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER (code=exited, status=1/FAILURE)
Process: 1306 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=1/FAILURE)
Process: 1282 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 807 (code=exited, status=1/FAILURE)

Jan 03 17:10:09 SERVER systemd[1]: Starting MariaDB 10.5 database server...
Jan 03 17:10:09 SERVER mysql-prepare-db-dir[1306]: Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty, so initialization cannot be done.
Jan 03 17:10:09 SERVER mysql-prepare-db-dir[1306]: Make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.
Jan 03 17:10:09 SERVER systemd[1]: mariadb.service: Control process exited, code=exited status=1
Jan 03 17:10:09 SERVER systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jan 03 17:10:09 SERVER systemd[1]: Failed to start MariaDB 10.5 database server.

after searching google for possible solution, then i realize that mysql directory is already exist on /var/lib and it contains data in it.

# ls -l
total 78296
-rw-rw---- 1 mysql mysql 16384 Jan 3 17:06 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 Jan 3 17:06 aria_log_control
-rw-r----- 1 mysql mysql 56 Nov 16 08:40 auto.cnf
-rw-r----- 1 mysql mysql 819 Nov 16 08:54 binlog.000001
-rw-r----- 1 mysql mysql 16 Nov 16 08:40 binlog.index
-rw------- 1 mysql mysql 1680 Nov 16 08:40 ca-key.pem
-rw-r--r-- 1 mysql mysql 1112 Nov 16 08:40 ca.pem
-rw-r--r-- 1 mysql mysql 1112 Nov 16 08:40 client-cert.pem
-rw------- 1 mysql mysql 1676 Nov 16 08:40 client-key.pem
-rw-r----- 1 mysql mysql 196608 Nov 16 08:42 '#ib_16384_0.dblwr'
-rw-r----- 1 mysql mysql 8585216 Nov 16 08:40 '#ib_16384_1.dblwr'
-rw-r----- 1 mysql mysql 3537 Nov 16 08:54 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Nov 16 08:54 ibdata1
drwxr-x--- 2 mysql mysql 4096 Nov 16 08:40 '#innodb_redo'
drwxr-x--- 2 mysql mysql 6 Nov 16 08:54 '#innodb_temp'
drwxr-x--- 2 mysql mysql 143 Nov 16 08:40 mysql
-rw-r----- 1 mysql mysql 25165824 Nov 16 08:41 mysql.ibd
-rw-r--r-- 1 mysql mysql 7 Nov 16 08:40 mysql_upgrade_info
drwxr-x--- 2 mysql mysql 8192 Nov 16 08:40 performance_schema
-rw------- 1 mysql mysql 1680 Nov 16 08:40 private_key.pem
-rw-r--r-- 1 mysql mysql 452 Nov 16 08:40 public_key.pem
-rw-r--r-- 1 mysql mysql 1112 Nov 16 08:40 server-cert.pem
-rw------- 1 mysql mysql 1680 Nov 16 08:40 server-key.pem
drwxr-x--- 2 mysql mysql 28 Nov 16 08:40 sys
-rw-r----- 1 mysql mysql 16777216 Nov 16 08:42 undo_001
-rw-r----- 1 mysql mysql 16777216 Nov 16 08:42 undo_002
[root@SERVER mysql]# pwd
/var/lib/mysql

and this data is from before today, so this data on mysql directory is not from mariadb 10.5 that i installed today.

so what i need to do is to empty this /var/lib/mysql directories or backup it to another directory so the /var/lib/mysql must be empty and then i start mariadb again by systemctl start mariadb and yes it start successfully now.

# systemctl start mysqld
# systemctl status mysqld
? mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2024-01-03 17:16:49 WIB; 4s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1618 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 1521 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
Process: 1497 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 1605 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 11 (limit: 4328)
Memory: 80.3M
CGroup: /system.slice/mariadb.service
??1605 /usr/libexec/mysqld --basedir=/usr

Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: The second is mysql@localhost, it has no password either, but
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: you need to be the system 'mysql' user to connect.
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: After connecting you can set the password, if you would need to be
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: able to connect as any of these users with a password and without sudo
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: See the MariaDB Knowledgebase at https://mariadb.com/kb
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: Please report any problems at https://mariadb.org/jira
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: The latest information about MariaDB is available at https://mariadb.org/.
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: Consider joining MariaDB's strong and vibrant community:
Jan 03 17:16:49 SERVER mysql-prepare-db-dir[1563]: https://mariadb.org/get-involved/
Jan 03 17:16:49 SERVER systemd[1]: Started MariaDB 10.5 database server.

This entry was posted in linux, my life, mysql | mariadb. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *