MySQL 8 Installation & Debezium/Kafka Connect User Setup on CentOS 8

MySQL 8 Installation & Debezium/Kafka Connect User Setup on CentOS 8

📘 MySQL 8 Installation & Debezium/Kafka Connect User Setup on CentOS 8

This guide explains how to:


✅ Prerequisites

You need:


🟦 Step 1 — Install MySQL 8

CentOS 8 ships with MySQL 8 in its official repositories.

Install MySQL:

sudo dnf install mysql-server

Start MySQL:

sudo systemctl start mysqld

Check service:

sudo systemctl status mysqld

Enable MySQL on boot:

sudo systemctl enable mysqld

🟦 Step 2 — Secure MySQL Installation

Run the MySQL secure installation script:

sudo mysql_secure_installation

This script allows you to:

Follow the prompts accordingly.


🟦 Step 3 — Configure MySQL for Debezium (Binary Log Settings)

Debezium requires MySQL binary logs (binlog).

Edit MySQL config:

sudo nano /etc/my.conf.d/mysql-server.cnf

Add or update:

[mysqld]
server-id=1
log_bin=mysql-bin
binlog_format=ROW
binlog_row_image=FULL
expire_logs_days=7

Restart MySQL:

sudo systemctl restart mysqld

Verify:

mysql -u root -p -e "SHOW VARIABLES LIKE 'log_bin';"
mysql -u root -p -e 'SHOW VARIABLES LIKE "binlog_format";'

Expected:


🟦 Step 4 — Login to MySQL

mysql -u root -p

🟦 Step 5 — Create Kafka Connect / Debezium User

Debezium requires specific permissions.

Create user with mysql_native_password:

CREATE USER 'kafkaconnector'@'%' 
IDENTIFIED WITH mysql_native_password 
BY 'StrongPassword123!';

Grant privileges:

GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT
ON *.* TO 'kafkaconnector'@'%';

Apply privileges:

FLUSH PRIVILEGES;

🟦 Step 6 — Allow Remote MySQL Connections (Optional)

Edit MySQL bind address:

sudo nano /etc/my.conf.d/mysql-server.cnf

Set:

bind-address = 0.0.0.0

Restart:

sudo systemctl restart mysqld

Allow MySQL through firewall:

sudo firewall-cmd --add-port=3306/tcp --permanent
sudo firewall-cmd --reload

🟦 Step 7 — Verify the Kafka/Debezium User

Inside MySQL:

SELECT user, host, plugin FROM mysql.user;

You should see:

kafkaconnector | % | mysql_native_password

Test remote login:

mysql -u kafkaconnector -p -h <MYSQL-IP>

🎉 MySQL is Ready for Kafka Connect & Debezium

You now have:

Next step: configure the Debezium MySQL connector in Kafka.