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.
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:-
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
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 apt repository website or with the wget command.
- MySQL apt Repository
- Locate the Ubuntu/Debian package
- Select Download
- If you don't have a MySQL account choose "No thanks, just start my download."
- On the MySQL apt Repository website locate the Ubuntu / Debian 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 dpkg -i mysql-apt-config_0.8.14-1_all.deb
- If your system platform version is unsupported you must select the closest compatible version from the provided list, then select OK
- Select OK
sudo apt-get update
sudo apt-get install mysql-community-server
sudo apt-get install libmysqlclient21
- Start MySQL and check the status
sudo systemctl start mysql
sudo systemctl status mysql
- 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 mysql
- It is highly recommended to harden security settings.
- Answer 'Y' to all questions (unless your organization's policies differ)
- During MySQL installation you would have set your root user password, you can skip changing it during this step
- 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 Schema to MySQL
mysql -u g2 -p G2 < senzing/resources/schema/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 G2Project.ini and G2Module.ini
Modify the following ini file to reference the new MySQL databases and schemas. This file is 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.
- 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
python3 G2Loader.py -P -p demo/sample/project.csv
- Create the G2 Export file