This section describes how to set up a training database using PostgreSQL on Linux. The database can be on a different machine to your Media Server.
To set up a PostgreSQL database on Linux
Install the PostgreSQL database server using your package manager.
TIP: PostgreSQL is installed by default on some Linux distributions, but it might be an older version. Your package manager might also offer an older version, unless you use the PostgreSQL yum or apt repositories (see https://www.postgresql.org).
Configure the database server for use with Media Server. The default configuration for a new PostgreSQL installation allows only local connections, so if your Media Server is on a different machine you might need to make the following changes:
postgresql.conf
and configure PostgreSQL to listen on an IP address and port. pg_hba.conf
, to allow your Media Server to connect to the database.Create a new database to store Media Server training data and set up the database schema that Media Server requires. To set up the schema, run the postgres.sql
script provided in the sql
folder of the Media Server installation directory.
Open a terminal and change directory to the sql
folder of the Media Server installation directory. This is important because the postgres.sql
script refers to other files in the same directory. For example:
cd /opt/MediaServer/sql
Start the psql
command-line tool as the postgres
user.
sudo -u postgres psql
Run a CREATE DATABASE
command to create a new database. Specify the following database settings.
Database name | Any name. |
Encoding | Must be Unicode–either UTF8 or UCS2. |
Collation | Any that is compatible with the encoding. |
Locale | Any that is compatible with the encoding. |
For example:
CREATE DATABASE mediatraining WITH ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8';
where mediatraining
is the name for the new database.
Connect to the new database:
\c mediatraining
(Optional) Run the following command to ensure a script stops running if it encounters an error:
\set ON_ERROR_STOP on
Run the postgres.sql
script provided in the sql
folder of the Media Server installation directory.
\i postgres.sql
Close the psql
tool.
\q
Create a user for Media Server to use and grant the following privileges to that user:
Grant... | On... |
---|---|
Create Temporary Tables | Database |
Select, Insert, Update, Delete | All tables |
Execute | All functions and stored procedures |
Usage | All sequences |
Start the psql
command-line tool.
sudo -u postgres psql
Create a new user:
CREATE USER mediaserver WITH LOGIN PASSWORD 'password';
where mediaserver
is the name of the new user, and password
is the password for the new user.
Grant the necessary privileges to the new user:
GRANT TEMP ON DATABASE mediatraining TO mediaserver; GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO mediaserver; GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO mediaserver; GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO mediaserver;
where mediatraining
is the name of the database you created and mediaserver
is the name of the user you created for Media Server.
Close the psql
tool.
\q
|