Mariadb.service is not starting

I followed the steps written in the archwiki page for mariadb. I did the following steps

sudo pacman -S mariadb

mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

But when i try to start it

sudo systemctl start mariadb.service

i get the following error

Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xeu mariadb.service" for details.

Here are the logs

systemctl status mariadb.service

    Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Sat 2023-04-22 17:32:24 IST; 5s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 1897 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1901 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_>
    Process: 1929 ExecStart=/usr/bin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
   Main PID: 1929 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"
        CPU: 210ms

Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Buffer pool(s) load completed at 230422 17:32:24
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] Server socket created on IP: '0.0.0.0'.
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] Server socket created on IP: '::'.
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Aborting
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: Warning: Memory not freed: 280
Apr 22 17:32:24 shashank-minotebook14 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Apr 22 17:32:24 shashank-minotebook14 systemd[1]: mariadb.service: Failed with result 'exit-code'.
Apr 22 17:32:24 shashank-minotebook14 systemd[1]: Failed to start MariaDB 10.11.2 database server.

journalctl -xeu mariadb.service

Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Number of transaction pools: 1
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Using liburing
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Completed initialization of buffer pool
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: 128 rollback segments are active.
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: log sequence number 36832; transaction id 4
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] InnoDB: Buffer pool(s) load completed at 230422 17:32:24
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] Server socket created on IP: '0.0.0.0'.
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [Note] Server socket created on IP: '::'.
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: 2023-04-22 17:32:24 0 [ERROR] Aborting
Apr 22 17:32:24 shashank-minotebook14 mariadbd[1929]: Warning: Memory not freed: 280
Apr 22 17:32:24 shashank-minotebook14 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE

How do i resolve this issue? Am i missing any step?

Hi,

have a look here

I applied this how to, it works on my side.

You forgot to initialize the system dstabase.

The above linked thread provide the needed help.

This command needs to be executed as root.
Check your datadir:

$ sudo ls -lha /var/lib/mysql