Setup for Examples

The example programs in the MariaDB Connector/J documentation require some databases, tables, and user accounts to be created in the MariaDB Enterprise Server environment.

Create the Schema

  1. Create the test database if it does not exist using the CREATE DATABASE statement with the IF NOT EXISTS clause:

    CREATE DATABASE IF NOT EXISTS test;
    
  2. Create tables in the test database using the CREATE TABLE statement:

    CREATE TABLE test.contacts (
       id INT PRIMARY KEY AUTO_INCREMENT,
       first_name VARCHAR(25),
       last_name VARCHAR(25),
       email VARCHAR(100)
    ) ENGINE=InnoDB;
    
    CREATE TABLE test.accounts (
       id INT PRIMARY KEY AUTO_INCREMENT,
       first_name VARCHAR(25),
       last_name VARCHAR(25),
       email VARCHAR(100),
       amount DECIMAL(15,2) CHECK (amount >= 0.0),
       UNIQUE (email)
    ) ENGINE=InnoDB;
    

Create the User

  1. Create a user account to test connectivity with the CREATE USER statement:

    CREATE USER 'db_user'@'192.0.2.1'
       IDENTIFIED BY 'db_user_password';
    
  2. Ensure that the user account has privileges to access the tables with the GRANT statement:

    GRANT CREATE, ALTER, SELECT, INSERT, UPDATE, DELETE, DROP
       ON test.contacts
       TO 'db_user'@'192.0.2.1';
    
    GRANT SELECT, INSERT, UPDATE, DELETE, DROP
       ON test.accounts
       TO 'db_user'@'192.0.2.1';
    

Password Guidance

Passwords should meet your organization's password policies. If your MariaDB Enterprise Server environment has a password validation plugin installed, the password must also meet the configured requirements.

By default, MariaDB Enterprise Server installs the simple_password_check plugin, configured with system variables: