Configuring a MySQL or MariaDB database
Before you begin
- Installed the MySQL or MariaDB database on a system.
MySQL and MariaDB are similar databases where you can choose one depending on your operating system and version. In a production environment, you install the database on a dedicated system. If you are evaluating Deploy, you can install the database on the same system as the Deploy server. See Databases for a list of supported database versions.
Refer to the MySQL Installation guide or MariaDB Installation guide for installation instructions.
- Set the database to start automatically on boot. For example, run the following command
on a Linux™ system that uses
systemctl:MariaDB:
systemctl enable mariadb; systemctl start mariadbMySQL:
systemctl enable mysqld; systemctl start mysqld - Set the database to use UTF-8 encoding:
- On the system that hosts the database, open the MySQL or MariaDB configuration file.
The location of the file depends on the operating system. On Linux, the file is named my.cnf, and many distributions, the file is located in the /etc or /etc/mysql folder. On Windows, the file is named as my.ini.
- In the
[mysqld]section of the configuration file, add the following lines:character-set-server=utf8 character-set-filesystem=utf8 - Apply the changes by restarting the database. For example, to restart MariaDB on
Linux, use this command:
systemctl restart mariadb
- On the system that hosts the database, open the MySQL or MariaDB configuration file.
- Changed the database to a case-sensitive collation.
About this task
Procedure
-
Open a command-line window and log in to the database.
MySQL:
mysql -u username -ppasswordMariaDB:mariadb -u username -ppasswordForusername, specify the user name for the database. The default user name isroot. Forpassword, specify the password for that user name. The default account has no password; in this case, omit the-pflag and the password.Note: Do not insert a space between the-pflag and the password. -
Create a database and user by running the following commands, replacing placeholders
with your specific values.
CREATE USER 'dbUser'@'localhost' IDENTIFIED BY 'password';
Where,CREATE DATABASE dbName DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;dbUseris the username for the database.dbNameis the database name. Such asdeploydb.utf8_binensures the required case-sensitive collation.
-
Grant all permissions to the database user.
GRANT ALL PRIVILEGES ON dbName.* TO 'dbUser'@'localhost'; FLUSH PRIVILEGES; - Log out of the database command line.
-
Obtain the database JDBC driver.
Refer to the official website of your specific database provider for downloading the appropriate JDBC driver. The driver files are specific to the database edition you are using.
When multiple drivers are available, you might need to consult with the database provider to determine which driver to use. The JDBC driver version that you must use might depend on the version of the database and the version of Java™ used by the Deploy server.
- Copy the JDBC JAR file to the installerDirectory\lib\ext folder.
What to do next
| Detail | MySQL default | MariaDB default |
|---|---|---|
| Database type | mysql |
mariadb |
| JDBC driver class | com.mysql.cj.jdbc.Driver |
org.mariadb.jdbc.Driver |
| Connection string | jdbc:mysql://dbURL:dbPORT/dbNAMEExample
connection string: |
jdbc:mariadb://dbURL:dbPORT/dbNAMEExample
connection string:
|
| Database username and password | See step 2. | See step 2. |