Databases

Nebula DB FAQs

1. Having a database(DB) is essential for many IoT monitoring applications. Nebula JAR devices use either MySQL or MariaDB, APK devices use Android’s native SQLite package. BIN devices can only serve as database clients as they typically don’t have sufficient memory or support packages for the role of server. To be clear, databases consist of clients that read data from and/or write data to a server whose role is to store the data in an organized manner. Being that clients are typically just HTTP clients, Nebula is a natural database client that can both read and write in Structured Query Language(SQL) via DB commands, meaning additional client side software is not necessary for Nebula.

2. You can add a database to any or all APK & JAR devices. The command/response and device tracking structure of Nebula permits great flexibility for constructing a network topology for different use cases.

3. To use an APK device for the Nebula database demonstration you only have to check “Requires Database” during installation. To use a JAR device requires installation of either a MySQL or MariaDB Server package with a user=nebula having password=nebula. When you check “Requires Database” during installation, Nebula will verify that a database is installed and the nebula user can connect to the database. If the requirements are met it will build the demo DB with table and columns.

4. With purchased Nebula you can add a database to a device at any time. The checkbox used during installation is simply a helper for demonstration purpose. It is recommended to go through the demonstration to become familiar with Nebula database usage. Afterwards you can setup a database of your own design more appropriate to your application. The Nebula databaseOps package has 5 classes:

  1. class DbHelper can create a DB, add its tables and connect to a DB.
  2. class DbSchema is used to describe tables and their columns.
  3. class DbInfo has methods to read, write and manipulate a DB.
  4. class SensorData builds objects from database query result sets.
  5. class LineChart is an example of graphical representation of DB values.

5. MySQL vs MariaDB commands are the same regardless.

6. SQLite vs MySQL SQLite is native in Android.

7. The package manager for Ubuntu and Beagleboard debian offer either DB. Latest Raspberry Pi Raspian offers only MariaDB. Mac OS users can get the MySQL .dmg installer or install MariaDB with homebrew.

Install a DB on Linux

Update the repositories to get the latest version.

sudo apt update

Install the MySQL package. All except Raspberry Pi Raspian.

sudo apt install mysql-server
OR

Install the MariaDB package.

sudo apt install mariadb-server

OPTIONAL: Add a root password or to allow removal of the root user to further secure your database.

sudo mysql_secure_installation

Launch the mysql or mariadb command line.

sudo mysql OR sudo mariadb

Now on DB command line (mysql> or MariaDB>) Create Nebula User



Uninstall DB from Linux

sudo apt purge DBtype
sudo apt autoremove

Check for any DB folders to delete

ls /var/lib


Install a DB on Windows

MySQL guide for installing on Windows.

MySQL download Get the mysql-installer-community-latest-stable-version.msi

MariaDB guide for installing on Windows.

MariaDB download Get the latest-stable-version.msi that suits(32 or 64) your platform.

  • The package requires the Microsoft Visual C++ 2015 Redistributable Package. The installer should take care of this for you.

  • You can use Custom Installation. The Nebula DB demo only needs the server. Nebula has connector JDBC 8.0.16 built-in.

  • Run the installer. Here’s some tips if the installer asks:

    Stand alone MySQL server
    Configuration Type - Development Computer
    root password - your choice just note it
    Install as a service - Yes
    No need to enable networking, Nebula handles that.
  • The ultimate goal is to get to the command line of the database to add the nebula user.

    1. Search for DBtype - Launch its command line if available
    2. Run C:\Program Files\DBtype\MaybeAnotherDir\bin\DBtype.exe
    3. Use your root password if asked
  • Now on DB command line (mysql> or MariaDB>) Create Nebula User



Uninstall DB from a Windows device.

  • Steps say MySQL but maybe use MariaDB

1. Search for and open Control Panel

1.1 Programs > Programs and Features > For each MySQL program > right-click then Uninstall.

1.2 Can also use Settings > Apps > For each MySQL program > click then Uninstall

After you have uninstalled all MySQL through Add/Remove programs, you now need to remove the existing database information which includes your actual data. If you need any of that data, be sure to back it up. Next you can delete the data directory.

2. Run Command Prompt as Administrator and execute the following command to stop and remove MySQL service.

2.1 Net stop MySQL – Stops the service

2.2 Sc delete MySQL – Deletes the service

3. Insure View shows hidden files and folders.

3.1 Now explore the following locations and delete following folders.

C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL

3.2 If it exists, delete the folder from the location.

C:\Users\[User-Name]\AppData\Roaming\MySQL

4. Restart your computer.



Install DB on Mac

MySQL download Mac get latest stable version .dmg

MySQL installation guide Mac

MariaDB guide Mac Install with homebrew

  • See the Windows section above for install tips.
  • The ultimate goal is to get to the command line of the database to add the nebula user.
  • When on DB command line (mysql> or MariaDB>) Create Nebula User


Create Nebula User

  • You should be on the DBtype> command line when you get to here. The semicolon at the end of command line is necessary.

1. INFO only: See root uses socket authenticate which is not correct for Nebula. We’ll make a correct user.

SELECT user,authentication_string,plugin,host FROM mysql.user;

2. Setup demo user and password. User and password are hard-coded in package databaseOps.DbHelper

CREATE USER 'nebula'@'localhost' IDENTIFIED BY 'nebula';

3. Give user nebula full privileges.

GRANT ALL PRIVILEGES ON *.* TO 'nebula'@'localhost' WITH GRANT OPTION;

4. Finished:

exit
  • May have to add DBtype to $PATH but installers typically take care of the need.
  • You can launch DBtype command line anytime with: DBtype -u nebula -pnebula

Now you can use the “Requires Database” checkbox on the Nebula installation screen to create the demo Database, Table and Columns. User nebula has full privileges to later create your own private user and drop the root user if you want.