Can't create database — permissions or already exists
Production Risk
Low — no data is affected, but missing privilege blocks schema provisioning.
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.
- 1User lacks the CREATE privilege on the target database
- 2OS-level permission prevents MySQL from creating the data directory
- 3Database name conflicts with a reserved system schema
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 ON *.* TO 'username'@'host'; FLUSH PRIVILEGES;
Why this works
The CREATE privilege allows the user to create new databases and tables.
✕ 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).
MySQL 8.0 — 1006 ER_CANT_CREATE_DB
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev