Error
Error Code:
1006
MariaDB Error 1006: Database Creation Failed
Description
This error indicates that the MariaDB server was unable to create a new database as requested. It typically occurs due to issues with permissions, system resources, or configuration on the server where MariaDB is running, preventing the successful allocation or initialization of the database files.
Error Message
Can't create database '%s' (errno: %d)
Known Causes
4 known causesInsufficient User Permissions
The MariaDB user attempting to create the database lacks the necessary `CREATE` privileges for the specified database or schema.
Disk Space or Quota Exceeded
The server's disk where MariaDB stores its data is full, or the user's disk quota has been reached, preventing new files from being written.
Invalid Database Name
The chosen database name contains unsupported characters, is a reserved keyword, or violates MariaDB's naming conventions.
Data Directory Issues
The MariaDB data directory is inaccessible, does not exist, or has incorrect permissions, preventing the server from creating database subdirectories.
Solutions
4 solutions available1. Grant CREATE Privilege easy
Give the user permission to create databases
1
Connect as root or admin user
mysql -u root -p
2
Grant CREATE privilege to the user
GRANT CREATE ON *.* TO 'username'@'host';
FLUSH PRIVILEGES;
3
Verify the privilege was granted
SHOW GRANTS FOR 'username'@'host';
2. Free Up Disk Space easy
Clear space on the data directory partition
1
Check available disk space
df -h /var/lib/mysql
2
Find and remove old binary logs
PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY);
3
Clean up unused databases
SHOW DATABASES;
DROP DATABASE unused_database_name;
4
Optimize large tables to reclaim space
OPTIMIZE TABLE database_name.table_name;
3. Fix Data Directory Permissions medium
Ensure MariaDB can write to data directory
1
Check current ownership of data directory
ls -la /var/lib/mysql/
2
Fix ownership to mysql user
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod 750 /var/lib/mysql
3
Verify SELinux isn't blocking (RHEL/CentOS)
sudo sestatus
sudo ls -laZ /var/lib/mysql/
4
If SELinux is blocking, restore context
sudo restorecon -Rv /var/lib/mysql/
4. Use Valid Database Name easy
Ensure database name follows MariaDB naming rules
1
Check MariaDB identifier rules and create with valid name
-- Valid names: letters, numbers, underscores
CREATE DATABASE my_database_123;
-- For special characters, use backticks
CREATE DATABASE `my-database`;
2
Avoid reserved words or quote them
-- These are reserved words - use backticks
CREATE DATABASE `database`;
CREATE DATABASE `select`;
3
Check maximum name length (64 characters)
-- This will fail - name too long
CREATE DATABASE this_is_a_very_long_database_name_that_exceeds_the_sixty_four_character_limit;