Warning
Error Code:
3824
MySQL Error 3824: Unencrypted Table in Encrypted DB
Description
This error indicates an attempt to create a table without explicit encryption in a MySQL database where default encryption is enabled. It arises when a `CREATE TABLE` statement doesn't specify an encryption option, conflicting with the database's security policy that mandates encryption for new tables.
Error Message
Creating an unencrypted table in a database with default encryption enabled.
Known Causes
3 known causesDatabase Default Encryption Active
The target MySQL database or tablespace has a configuration setting (e.g., `default_table_encryption=ON`) that requires all newly created tables to be encrypted by default.
Missing Encryption Clause in CREATE TABLE
The SQL `CREATE TABLE` statement used to define the new table did not include an `ENCRYPTION='Y'` or similar clause, causing it to be considered unencrypted.
Unawareness of Encryption Policy
The user or application creating the table was not aware that the database or tablespace they are targeting has a default encryption policy in place.
Solutions
3 solutions available1. Explicitly Encrypt the New Table easy
Manually specify encryption for the table being created.
1
When creating the new table, explicitly add the `ENCRYPTION='Y'` clause.
CREATE TABLE my_encrypted_table (
id INT PRIMARY KEY,
data VARCHAR(255)
) ENCRYPTION='Y';
2. Disable Default Encryption for the Database medium
Temporarily or permanently turn off default encryption for the affected database.
1
Connect to your MySQL server and select the database.
USE your_database_name;
2
Check the current default encryption setting.
SHOW VARIABLES LIKE 'default_table_encryption';
3
If `default_table_encryption` is ON, disable it for the current session (this is temporary and will reset after the server restarts).
SET GLOBAL default_table_encryption = OFF;
4
Alternatively, to make this change permanent, you need to modify the MySQL configuration file (`my.cnf` or `my.ini`). Locate the `[mysqld]` section and add or modify the following line. Then restart the MySQL server.
[mysqld]
default_table_encryption=OFF
5
After disabling default encryption, create your table as usual.
CREATE TABLE my_new_table (
id INT PRIMARY KEY,
data VARCHAR(255)
);
6
If you wish to re-enable default encryption later, repeat steps 3 and 4, setting `default_table_encryption` to `ON`.
SET GLOBAL default_table_encryption = ON;
3. Convert Existing Tables to Encryption advanced
If the goal is for all tables in the database to be encrypted, convert existing ones.
1
First, ensure default encryption is enabled for the database (if it's not already).
SET GLOBAL default_table_encryption = ON;
2
Identify tables that are not encrypted. You can query the `information_schema.tables` view.
SELECT table_schema, table_name
FROM information_schema.tables
WHERE encryption = 'N' AND table_schema = 'your_database_name';
3
For each unencrypted table, you can convert it to an encrypted table by using `ALTER TABLE ... ENCRYPTION='Y'`. Note: This operation can be resource-intensive on large tables and may require downtime or careful planning.
ALTER TABLE your_database_name.your_unencrypted_table ENCRYPTION='Y';
4
After converting existing tables, you can then create new tables without explicitly specifying encryption, as they will inherit the default.
CREATE TABLE my_new_encrypted_table (
id INT PRIMARY KEY,
data VARCHAR(255)
);