Setup for Examples

Overview

The examples in the MariaDB Connector/Node.js documentation depend on a database test and table contacts.

Create the Schema

  1. Create a test database if one does not exist with the CREATE DATABASECREATE DATABASE statement:

    CREATE DATABASE IF NOT EXISTS test;
    
  2. Create a table called contacts to test the Promise and Callback API functions:

    CREATE TABLE IF NOT EXISTS test.contacts (
       id INT PRIMARY KEY AUTO_INCREMENT,
       first_name VARCHAR(25),
       last_name VARCHAR(25),
       email VARCHAR(100)
    ) ENGINE = InnoDB;
    

Create the User

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

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

    GRANT ALL PRIVILEGES
    ON test.*
    TO 'db_user'@'192.0.2.50';