Setting up the REST Application Database
To install a REST API to interact with Metron, complete the following steps:
Connect to MySQL and create a Metron REST database:
mysql -uroot -p CREATE DATABASE IF NOT EXISTS metronrest;
Create a Metron user in MySQL with a password, then apply database access permission to the Metron user:
CREATE USER 'metron'@'$REST_HOST' IDENTIFIED BY 'Myp@ssw0rd'; GRANT ALL PRIVILEGES ON metronrest.* TO 'metron'@'$REST_HOST';
Create user and authorities tables:
use metronrest; create table if not exists users( username varchar(50) not null primary key, password varchar(50) not null, enabled boolean not null ); create table authorities ( username varchar(50) not null, authority varchar(50) not null, constraint fk_authorities_users foreign key(username) references users(username) ); create unique index ix_auth_username on authorities (username,authority);
Add one or more users to the REST application:
use metronrest; insert into users (username, password, enabled) values ('your_username', 'your_password',1); insert into authorities (username, authority) values ('your_username', 'ROLE_USER');
Exit MySQL:
quit
If you have not already done so, install the appropriate MySQL client library for your version of MySQL. For example:
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5. 1.41.tar.gz tar xf mysql-connector-java-5.1.41.tar.gz
Tell the server to reload the grant tables.
flush privileges
To add additional users:
use metronrest; insert into users (username, password, enabled) values ('your_username', 'your_password',1); insert into authorities (username, authority) values ('your_username', 'ROLE_USER'); commit;