# 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 &amp; Debezium/Kafka Connect User Setup on CentOS 8

This guide explains how to:

- Install MySQL 8 on CentOS 8
- Secure the MySQL installation
- Enable remote access
- Create a user for Debezium/Kafka Connect
- Configure the user to use **mysql\_native\_password**
- Enable MySQL binlog for CDC (Change Data Capture)

---

# ✅ Prerequisites

You need:

- A **CentOS 8** server
- A **non-root user** with sudo privileges
- **firewalld** enabled

---

# 🟦 Step 1 — Install MySQL 8

CentOS 8 ships with MySQL 8 in its official repositories.

Install MySQL:

```bash
sudo dnf install mysql-server

```

Start MySQL:

```bash
sudo systemctl start mysqld

```

Check service:

```bash
sudo systemctl status mysqld

```

Enable MySQL on boot:

```bash
sudo systemctl enable mysqld

```

---

# 🟦 Step 2 — Secure MySQL Installation

Run the MySQL secure installation script:

```bash
sudo mysql_secure_installation

```

This script allows you to:

- Set root password
- Remove anonymous users
- Disable root remote login
- Remove test DB
- Reload privilege tables

Follow the prompts accordingly.

---

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

Debezium requires MySQL binary logs (binlog).

Edit MySQL config:

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

```

Add or update:

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

```

Restart MySQL:

```bash
sudo systemctl restart mysqld

```

Verify:

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

```

Expected:

- `log_bin = ON`
- `binlog_format = ROW`

---

# 🟦 Step 4 — Login to MySQL

```bash
mysql -u root -p

```

---

# 🟦 Step 5 — Create Kafka Connect / Debezium User

Debezium requires specific permissions.

Create user with **mysql\_native\_password**:

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

```

Grant privileges:

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

```

Apply privileges:

```sql
FLUSH PRIVILEGES;

```

---

# 🟦 Step 6 — Allow Remote MySQL Connections (Optional)

Edit MySQL bind address:

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

```

Set:

```
bind-address = 0.0.0.0

```

Restart:

```bash
sudo systemctl restart mysqld

```

Allow MySQL through firewall:

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

```

---

# 🟦 Step 7 — Verify the Kafka/Debezium User

Inside MySQL:

```sql
SELECT user, host, plugin FROM mysql.user;

```

You should see:

```
kafkaconnector | % | mysql_native_password

```

Test remote login:

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

```

---

# 🎉 MySQL is Ready for Kafka Connect &amp; Debezium

You now have:

- A working MySQL 8 server
- Secured installation
- Enabled binlog for CDC
- A Debezium/Kafka-ready user
- Compatible **mysql\_native\_password** authentication

Next step: configure the Debezium MySQL connector in Kafka.