Configure MariaDB

Last modified by Eleni Cojocariu on 2026/07/24 14:27

Content

Steps

Warning

WIP

MariaDB is a drop-in replacement for MySQL. The installation is similar to MySQL's, but there are a few differences. To configure MariaDB as the database for XWiki:

  1. Make sure you have already installed and configured a servlet container for XWiki (e.g. Tomcat or Jetty), with the XWiki WAR file extracted/deployed.
  2. Download and install MariaDB following its official instructions. See the Database support strategy for supported versions.
  3. Download the MariaDB JDBC driver and copy it into the XWiki webapp's WEB-INF/lib directory of the servlet container chosen.

    Download the MariaDB Connector/J, or get it from the Maven Central Repository. The JAR file is named mariadb-java-client-*.jar.

  4. Create the xwiki database user and the xwiki database. Use the mysql command-line client:
    • Log in as root:
      mysql -u root -p
    • Create the database with the required encoding:
      CREATE DATABASE xwiki CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
    • Create the xwiki user:
      CREATE USER 'xwiki'@'localhost' IDENTIFIED BY 'xwiki';
    • Replace 'xwiki' with a strong password for production environments.
    • Grant all privileges on the database:
      GRANT ALL PRIVILEGES ON xwiki.* TO 'xwiki'@'localhost';
      FLUSH PRIVILEGES;
    • Verify the database was created:
      SHOW DATABASES;
  5. Configure XWiki to use MariaDB. Open WEB-INF/hibernate.cfg.xml, uncomment the existing MariaDB configuration block in your XWiki webapp and set the connection values:
        <property name="hibernate.connection.url">jdbc:mariadb://localhost/xwiki?useSSL=false</property>
        <property name="hibernate.connection.username">xwiki</property>
        <property name="hibernate.connection.password">xwiki</property>
        <property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
        <property name="hibernate.dbcp.poolPreparedStatements">true</property>
        <property name="hibernate.dbcp.maxOpenPreparedStatements">20</property>
    
        <property name="hibernate.connection.charSet">UTF-8</property>
        <property name="hibernate.connection.useUnicode">true</property>
        <property name="hibernate.connection.characterEncoding">utf8</property>
    Adjust the host, port, or database name if your setup differs. For production environments, configure SSL and use a strong password.
  6. Restart XWiki to apply the changes.

FAQ

Can I use a different database name or user?

Yes. Replace xwiki with your preferred names in the creation steps and in the connection.url property.

How do I remove the database if needed?

Log in as root and run:

DROP DATABASE xwiki;
DROP USER 'xwiki'@'localhost';

What database encoding and collation should I use?

XWiki expects the database to use UTF-8 encoding with a binary collation. It supports both utf8 and utf8mb4, but utf8mb4 with the utf8mb4_bin collation is strongly recommended.

Get Connected