Install a Database for FusionAuth
On this page
FusionAuth requires a database that meets the System Requirements. FusionAuth supports PostgreSQL and MySQL, and FusionAuth tests only with PostgreSQL.
Use PostgreSQL 15 or newer.
For FusionAuth versions before 1.43.0, use PostgreSQL 14, because those versions don't support PostgreSQL 15 or newer.
To install PostgreSQL, follow the installation instructions for your platform at postgresql.org.
To install PostgreSQL with Homebrew:
-
Install PostgreSQL:
$ brew install postgresql@16 -
Start PostgreSQL with Homebrew services:
$ brew services start postgresql@16 -
To add the PostgreSQL binaries to your
PATH, add the following line to your~/.zshrcor~/.bashrcfile:export PATH="$PATH:$(brew --prefix postgresql@16)/bin"
Then, configure PostgreSQL for FusionAuth:
-
Create the FusionAuth user,
fusionauth, with passwordfusionauth:$ psql --command="CREATE USER fusionauth PASSWORD 'fusionauth'" --command="\du" postgres -
Create a database named
fusionauthowned by thefusionauthuser:$ createdb --owner=fusionauth fusionauth
To install MySQL, follow the installation instructions for your platform at dev.mysql.com.
data fieldsOn MySQL, the data field of a User or Registration holds up to 16 MB. The data field of an Application or Tenant holds less than 64 KB, because the same column stores the rest of the configuration. On PostgreSQL, the API request limits cap a data field well before the column fills. For more information, see Data Field Sizes.
FusionAuth stores 4-byte Unicode characters, so MySQL must use the utf8mb4 character set. When MySQL uses a different character set, FusionAuth fails to start and logs an error. To configure the character set:
-
Add the following lines to
my.cnf(my.inion Windows):[client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_bin -
Restart MySQL to load the configuration.
The configuration changes the character set for the entire MySQL server. When other databases and applications share the MySQL server, check that the change doesn't break them.
When FusionAuth still fails the utf8mb4 check at startup after you configure MySQL, you can turn off the check with database.mysql.enforce-utf8mb4. For more information, see the Configuration reference.
FusionAuth also needs MySQL Connector/J, the MySQL JDBC driver. The Oracle license for the driver doesn't allow FusionAuth to bundle the driver, so you install the driver yourself:
- Download MySQL Connector/J
8.0.23or newer, using the Platform Independent option, from Oracle. - Unzip or untar the archive.
- Copy the driver
.jarfile from the archive tofusionauth-app/libin the FusionAuth installation directory. Newer versions name the filemysql-connector-j-<version>.jar, and older versions name the filemysql-connector-java-<version>.jar. For example, a DEB package on Debian Linux installs FusionAuth to/usr/local/fusionauth, so you copy the file to/usr/local/fusionauth/fusionauth-app/lib.