1006
MySQLERRORCommonDDLHIGH confidence

Can't create database — permissions or already exists

Production Risk

Low — no data is affected, but missing privilege blocks schema provisioning.

What this means

ER_CANT_CREATE_DB (1006, SQLSTATE HY000) is raised when CREATE DATABASE fails, typically because the user lacks the CREATE privilege or the operating-system directory cannot be created.

Why it happens
  1. 1User lacks the CREATE privilege on the target database
  2. 2OS-level permission prevents MySQL from creating the data directory
  3. 3Database name conflicts with a reserved system schema
How to reproduce
trigger — this will error
trigger — this will error
CREATE DATABASE new_db;

expected output

ERROR 1006 (HY000): Can't create database 'new_db' (errno: 13)

Fix

Grant CREATE privilege and check OS directory permissions

WHEN User does not have CREATE privilege.

Grant CREATE privilege and check OS directory permissions
GRANT CREATE ON *.* TO 'username'@'host';
FLUSH PRIVILEGES;

Why this works

The CREATE privilege allows the user to create new databases and tables.

What not to do

✕ Run MySQL server as root OS user to bypass permission errors

Running mysqld as root is a serious security risk; fix the data directory ownership instead (chown -R mysql:mysql /var/lib/mysql).

Sources
Official documentation ↗

MySQL 8.0 — 1006 ER_CANT_CREATE_DB

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors