---
title: "Configuring MySQL"
source: https://dev.pageseeder.com/guide/installation/mysql.html
description: "Guide for configuring MySQL 8.4 on Rocky 9 for PageSeeder v6+, covering installation, security, JDBC driver setup, performance tuning, and database backup/restore procedures."
last_updated: 2026-09-14T14:45:36+10:00
tokens: ~1718
---

# Configuring MySQL

The following instructions are for **PageSeeder v6 or higher**,  **MySQL 8.4** and **Rocky 9** (or equivalent Red Hat family distributions).

## Install MySQL 8.4

If this is a new installation of PageSeeder v6 or higher, it’s generally best to install the latest release of MySQL 8.4 from [https://www.mysql.com](https://www.mysql.com/). If you are using PageSeeder v5 or must install an earlier MySQL version see [Configuring MySQL 5.7](/guide/installation/configuring_mysql_5.7.md).

Install the repository RPM by entering:

```shell
# dnf install -y https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
```

Install MySQL:

```shell
# dnf install -y mysql-community-server
```

Start and enable the service:

```shell
# systemctl start mysqld
# systemctl enable mysqld
```

### Secure MySQL

The default MySQL security settings are vulnerable to attacks, but you can improve security by running the `mysql_secure_installation` script, which modifies default options and strengthens the database.

MySQL 8.4 generates a temporary password which you can get with

```shell
# grep 'A temporary password is generated' /var/log/mysqld.log | tail -1
```

Run the following command in your shell to start the script:

```shell
# mysql_secure_installation
```

Then:

1. Enter the temporary root password generated by MySQL
2. Enter the new root password – the one you intend to use, and keep a copy in secret
3. Answer ‘**N**’ to changing the root password since you’ve just done it!
4. Answer ‘**Y**’ to all the other questions.

> **Note:** Later, in the PageSeeder setup screen, you must enter these details under **Database administrator:** login name and password or as parameter for the `setup.sh` shell script.

### Changing where data is stored

On Linux, MySQL usually stores data under `/var/lib/mysql`, but if you want to use mounted storage for PageSeeder (for example storage mapped to the `/opt` folder), you can configure MySQL to store data there as well. To do this, follow these steps:

Stop MySQL by entering:

```shell
# systemctl stop mysqld
```

Move the existing MySQL data to the new location:

```shell
# mv /var/lib/mysql /opt/mysql
```

Edit the `/etc/my.cnf` file as follows:

```ini
[mysqld]
...
datadir=/opt/mysql
socket=/opt/mysql/mysql.sock
...
[client]
socket=/opt/mysql/mysql.sock
```

Start MySQL by entering:

```shell
# systemctl start mysqld
```

> **Note:** If MySQL doesn’t start after changing the data location, SELinux might need to be configured to allow access to the new location by entering the following: ```shell # semanage fcontext -a -t mysqld_db_t '/opt/mysql(/.*)?' # restorecon -Rv /opt/mysql ```

## Install the JDBC driver

The PageSeeder app requires a JDBC driver to communicate with MySQL. PageSeeder v6 or higher requires **Connector/J v8.4**. Download the latest version of MySQL Connector/J (JDBC Driver) for your MySQL and extract it on your server.

- On Windows, it can be downloaded from [https://www.mysql.com](https://www.mysql.com/) . Subject to Oracle/MySQL website changes, Connector/J is under ‘MySQL Community Downloads’ and older versions are listed under ‘Archive’.
- On Linux, use the following commands to download it **to your `/home/[user]` directory** *(URL and version might have changed)*:

```shell
# wget https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-j-8.4.0.tar.gz
# tar xzvf mysql-connector-j-8.4.0.tar.gz --wildcards '*.jar'
```

*The PageSeeder installer asks for the location of the JDBC driver JAR file to be identified.*

## Tune MySQL

MySQL performance should be tuned on production servers. To do this increase the InnoDB buffer to 75% of total RAM, minus 500MB (MySQL with 100 connections) and what is used by other processes (PageSeeder/java can use 20% more than its configured `-Xmx` heap size). For example, with 8GB total RAM and PageSeeder 2GB heap, the InnoDB buffer could be set to 3GB ( 8 x .75 - 0.5 - 2.4) as follows:

Edit the `/etc/my.cnf` file and below** `[mysqld]` **add:

```properties
innodb-buffer-pool-size=3072M
```

or:

```properties
innodb-buffer-pool-size=3G
```

Restart MySQL by entering:

```shell
# systemctl restart mysqld
```

> **Note:** To increase the number of Database connections, see [Database Properties](/guide/configuration/properties/database_properties.md).

## Backup and restore

To backup the PageSeeder database on Linux use a command like this:

```shell
# mysqldump --single-transaction -u root -p -r ps.sql pageseeder
```

Optionally compress the backup:

```shell
# gzip ps.sql
```

### Restore with overwrite

To overwrite an existing database, first drop it, then recreate it using commands like this:

```shell
# mysql -u root -p
drop database pageseeder;
create database pageseeder character set utf8mb4;
grant all on pageseeder.* to pageseeder@localhost;
quit
```

To restore the PageSeeder database, use a command like this:

```shell
# mysql -u pageseeder -p pageseeder < ps.sql
```

or if the backup is compressed:

```shell
# gunzip -c ps.sql.gz | mysql -u pageseeder -p pageseeder
```

### Restore with create

If no database or user exists, create them using commands like this:

```shell
# mysql -u root -p
create database pageseeder character set utf8mb4;
create user pageseeder@localhost identified by '<password>';
grant all on pageseeder.* to pageseeder@localhost;
quit
```

To restore the PageSeeder database use a command like this:

```shell
# mysql -u pageseeder -p pageseeder < ps.sql
```

or if the backup is compressed:

```shell
# gunzip -c ps.sql.gz | mysql -u pageseeder -p pageseeder
```

> **Note:** If PageSeeder is running on a different server to MySQL, replace `@localhost` with `@"%"`

> **Note:** On Linux, if you get an error `ERROR 2006 (HY000) at line 207: MySQL server has gone away` while restoring, add `max_allowed_packet=32M` under `[mysqld]`in the `/etc/my.cnf` file and restart MySQL before trying again.

### After restore

After restoring the database on a production server run the following commands to ensure best performance:

```shell
# mysql -u pageseeder -p
use pageseeder;
ANALYZE TABLE AUTHENTICATOR;
ANALYZE TABLE CLIENT;
ANALYZE TABLE CONTENT;
ANALYZE TABLE DATABASE_METADATA;
ANALYZE TABLE DGROUP;
ANALYZE TABLE DGROUPURI;
ANALYZE TABLE DGROUPURI_FOR_DGROUP;
ANALYZE TABLE DGROUP_FOR_DGROUP;
ANALYZE TABLE DGROUP_FOR_XLINK;
ANALYZE TABLE HOST;
ANALYZE TABLE HOSTALIAS;
ANALYZE TABLE LOCATOR;
ANALYZE TABLE LOCATOR_FOR_URI;
ANALYZE TABLE LOCATOR_FOR_XLINK;
ANALYZE TABLE MEMBER;
ANALYZE TABLE MEMBER_FOR_DGROUP;
ANALYZE TABLE MEMBER_GROUP_DETAILS;
ANALYZE TABLE MODERATOR;
ANALYZE TABLE PERSISTENT_TOKEN;
ANALYZE TABLE PUBLICATION_FOR_LOCATOR;
ANALYZE TABLE URI;
ANALYZE TABLE URI_FOR_DGROUPURI;
ANALYZE TABLE WEBHOOK;
ANALYZE TABLE XLINK;
ANALYZE TABLE XLINK_FOR_ATTACHEDXLINK;
ANALYZE TABLE XLINK_FOR_XLINK;
```

