MySQL throws ER_CANT_CREATE_DB (error 1006) when it cannot create a new database schema due to file-system, permission, or configuration problems.
MySQL Error 1006: ER_CANT_CREATE_DB appears when the server cannot create the requested database schema. Check file-system permissions, storage engine configuration, and free disk space, then recreate the database with corrected settings to resolve the issue.
Can't create database '%s' (errno: %d)
The server raises this error when a CREATE DATABASE statement fails. MySQL returns: "Can't create database 'db_name' (errno: n)" where n is a lower-level OS or storage-engine error code. The failure happens before any tables are written, so no rollback is required.
Fixing the problem matters because applications that auto-provision tenants, CI pipelines, and installation scripts all halt when the database cannot be created.
Understanding the underlying errno helps you correct the environment quickly.
MySQL maps internal error 1006 to many OS-level issues. Common triggers include missing file-system permissions, insufficient disk space, conflicting schema directories, damaged data directories, and misconfigured default storage engines.
Networked or containerized deployments add extra causes such as read-only volumes, SELinux or AppArmor blocks, and Docker bind mount misconfigurations.
First, read the errno in the message.
Errno 13 means "permission denied"; errno 28 means "no space left on device". Resolve that root issue, then re-run CREATE DATABASE. Use SHOW WARNINGS right after the failed statement for more context.
Next, verify the storage engine. If the default engine directory is missing, recreate it or edit my.cnf to point to a valid location, then restart MySQL.
On Linux, MySQL running as mysql:mysql cannot write to /var/lib/mysql because directory permissions changed.
Restore 770 or 750 and chown recursively, then retry.
Inside Docker, the host path mapped to /var/lib/mysql is read-only. Recreate the volume with rw access or pass -v host:/var/lib/mysql:rw in docker run.
Automate file-system checks in deployment scripts: verify ownership, free space thresholds, and SELinux contexts before launching MySQL.
Configure alerting for df -h and inode exhaustion.
Using Galaxy’s desktop SQL editor, add a pre-migration step in your collection that runs SHOW VARIABLES LIKE 'datadir'; and validates write access, preventing 1006 during CI/CD runs.
Error 1007 (ER_DB_CREATE_EXISTS) occurs when the schema already exists. DROP DATABASE or use IF NOT EXISTS.
Error 1016 (ER_CANT_OPEN_FILE) signals MySQL cannot open a table file, often due to the same permission issues. Fixing ownership usually resolves both 1006 and 1016.
.
The MySQL user lacks write access to the data directory or parent directory where the schema folder is created.
The partition hosting the MySQL datadir is out of disk space or inodes, blocking new directory creation.
A file with the same name as the intended database directory exists, preventing MySQL from creating a folder.
InnoDB or other engine directories were deleted, moved, or specified incorrectly in my.cnf, making CREATE DATABASE fail.
SELinux, AppArmor, or container volume policies mark the datadir read-only, causing MySQL to raise error 1006.
.
No. Errno values define the exact reason. errno 13 is permission, errno 28 is disk space, and other codes map to different issues.
No. The database was not created. Subsequent table creation will fail. Fix the root cause, then rerun CREATE DATABASE.
Dropping the entire datadir removes all databases. Only delete or rename the conflicting directory for the single schema.
Galaxy lets you run pre-flight SQL checks and share endorsed setup scripts that validate disk space and permissions before deployments.