By default Senzing is set to use an embedded SQLite database. This article describes the steps to configure Senzing to use MySQL as the entity repository and how to create the Senzing schema within a MySQL database.
CentOS 7 was used in testing the steps outlined herein and the latest version of MySQL available at the time; which was 8.0.12. This article assumes you are already a MySQL user or familiar with MySQL, it only briefly covers the installation steps of MySQL. If you require additional MySQL information the following links will be useful:-
Warning: CentOS 7 will install MariaDB if you use yum to try and install MySQL. MariaDB is a fork of MySQL and is generally preferred on CentOS. If you'd like to use MariaDB we have an article specifically for MariaDB.
In addition to the dependencies outlined in the Introduction: Quickstart article the following operating system prerequisites and packages are required. You must ensure the dependencies in the quickstart article are met before proceeding.
- sudo or root privileges to install MySQL and issue system commands
- unixODBC and unixODBC-devel
sudo yum install unixODBC unixODBC-devel
sudo yum install gcc-c++
sudo pip install pyodbc
Note: If you are working on a system that already has a MySQL V5.x server installed and are skipping the setup on a new MySQL V8 server please review MySQL V8.0 ODBC client alongside V5.x Server before continuing.
Install and Basic MySQL Setup
The following is a brief overview of the steps required to install MySQL. For full details on installing MySQL on Linux please see Installing, and Upgrading MySQL.
Download the repository installation package directly from the yum repository website or with the wget command.
- MySQL Yum Repository
- Locate the Red Hat Enterprise Linux 7 / Oracle Linux 7 package
- Select Download
- If you don't have a MySQL account choose "No thanks, just start my download."
- On the MySQL Yum Repository website locate the Red Hat Enterprise Linux 7 / Oracle Linux 7 package and then the package name in brackets under the title
- Use wget with this name string to directly download the package
- Once downloaded add the repository information by installing the package, and then installing MySQL.
sudo yum localinstall mysql80-community-release-el7-1.noarch.rpm
sudo yum install mysql-community-server
- Start MySQL and check the status
sudo systemctl start mysqld
sudo systemctl status mysqld
- If started successfully you will see output similar to the following
- MySQL will autostart at system boot, if you'd like to disable autostarting issue
sudo systemctl disable mysqld
- It is highly recommended to harden security settings. First acquire the default root password post installation and then run the MySQL security hardening script
sudo grep 'temporary password' /var/log/mysqld.log
- Use the temporary password shown from the grep command above
- The new password must be at least 12 chars, one upper, one lower, one number and one special character
- Answer 'Y' to all questions (unless your organization's policies differ)
- Test connection and setup G2 user. Check the following permissions meet your organisations policies. The user name 'g2' is used in the following example, change as appropriate to the user id your G2 installation is run under
mysql -u root -p
- You will be prompted for your new root password
create user 'g2'@'%' identified by '<g2_user_password>';
- Change <g2_user_password> to your desired password to access MySQL
- Password must be at least 12 chars, one upper, one lower, one number and one special character
grant all privileges on G2.* to 'g2'@'%';
- Test the new g2 user and create the G2 databases
mysql -u g2 -p
- You will be prompted for the password you used for <g2_user_password>
create database G2 character set=utf8 collate=utf8_bin;
Add Senzing Schemas to MySQL
mysql -u g2 -p G2 < /opt/senzing/g2/data/g2core-schema-mysql-create.sql
- g2 = User id previously used in above commands, substitute your user id if different
- -p = Will prompt for the password you used for <g2_user_password>
- /opt/senzing/g2/... = Default Senzing deployment directory
Configure and Test ODBC
Install the MySQL ODBC connectors.
sudo yum install mysql-connector-odbc
Once installed, add the following entries to /etc/odbc.ini, you need to edit the file with root/sudo privileges.
Driver = MYSQL
Database = G2
Server = 127.0.0.1
Port = 3306
Modify /etc/odbcinst.ini (also with root/sudo) and comment out the stanza header for [MySQL ODBC 8.0 Unicode Driver] and add the [MYSQL] header. If you already have a [MYSQL] stanza section are not using it (from an old driver) you can comment out the entire old [MYSQL] section.
#[MySQL ODBC 8.0 Unicode Driver]
Test ODBC is working with MySQL against the G2 database, you should see a result set of count =0 from the SQL select statement.
isql -v G2 g2 <user_password>
select count(*) from OBS_ENT;
Confgure G2Project.ini and G2Module.ini
Modify the following ini files to reference the new MySQL databases and schemas. These files are located in /opt/senzing/g2/python (if you've not altered the default location). You can comment out the current lines by prefixing them with # and adding the modified ones below.
- G2Project.ini - Change the G2Connection and ODSConnection strings to
- G2Module.ini - Change the CONNECTION string to
- g2 = G2 userid
- password4g2 = Password for the G2 userid
- 127.0.0.1 = G2 server address
- 3306 = MySQL port number
Run a Test G2 Load and G2 Export
Perform a test load of the supplied sample data and then perform a G2 export creation to test the new database setup.
- Source setupEnv
- Load the G2 sample data
python G2Loader.py -P -p demo/sample/project.csv
- Create the G2 export file