# Enabling CDC on your Database

The Debezium framework has some DB connectors to capture data changes (CDC), but to work properly, the DB should also be properly configured.

### **MySQL**

For that Db should be enabled binary logging.

To check it enough to execute the following query -&#x20;

```html
show master status 
or 
for AWS - show variables like 'log_bin'
```

If we have any records in the result, it means - bin log is enabled and Debezium will handle data changes.&#x20;

Some additional info - how to configure the Amazon instance can find [here](https://repost.aws/knowledge-center/enable-binary-logging-aurora)

Also, it should be ROW type

### Postgres

```
     SHOW wal_level;

if wal_level does not equal logical execute command below:

     ALTER SYSTEM SET wal_level = logical;
```

and restart the DB instance.

### **MS SQL SERVER:**<br>

SQLSERVER agent should be enabled

For the docker image use the following

```
$ docker exec -it --user root CONTAINER_ID /bin/sh


root@57301203bac5:/# /opt/mssql/bin/mssql-conf set sqlagent.enabled true 

SQL Server needs to be restarted in order to apply this setting. Please run 'systemctl restart mssql-server.service'. 

root@57301203bac5:/# systemctl restart mssql-server.service

```

Execute the following query to check whether CDC is enabled or not.

```
select
   name,
   is_cdc_enabled
from sys. databases
where name = '{{DB_NAME}}';
```

If CDC is disabled, execute the following script:

```
USE {{DB_NAME}};
GO

EXECUTE sys.sp_cdc_enable_db;
GO
```

Check in CDC enabled for the table&#x20;

```
select name, is_tracked_by_cdc
from sys. tables
where name = 'YourTableName';

```

Then for EACH table execute the script provided below:

```
EXEC sys.sp_cdc_enable_table
    @source_schema=N'{{SCHEMA_NAME}}',
    @source_name=N'{{TABLE_NAME}}',
    @role_name = NULL,
    @supports_net_changes=0
GO

```

Then execute

```
EXEC sys.sp_cdc_add_job @job_type = N'capture';
GO

EXEC sys.sp_cdc_start_job @job_type = 'capture'
GO
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mydbsync.com/cloud-replication-main/cdc-database-replication/enabling-cdc-on-your-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
