The MySQL error “Can’t create database ‘newdbname’ (errno: 28)” usually occurs when there is insufficient disk space on your server or partition where the MySQL data directory resides.
mysql> CREATE DATABASE newdbname; ERROR 1006 (HY000): Can't create database 'newdbname' (errno: 28)
This guide will show you how to troubleshoot and fix this issue.
Step 1: Check available disk space
First, verify the available disk space on your server by running the following command:
df -h
This command will display the disk usage and free space for all mounted partitions. Pay attention to the partition where your MySQL data directory is located (usually /var/lib/mysql).
Step 2: Free up disk space
If there is indeed insufficient space on the partition, consider taking the following actions to free up some disk space:
- Delete unnecessary files and directories.
- Remove or archive old logs.
- Clear cache or temporary files.
- Uninstall unused software packages.
- Move non-critical data to another partition or an external storage device.
Step 3: Verify MySQL data directory permissions
Ensure that the MySQL data directory has the proper permissions and is owned by the MySQL user. To check the permissions and ownership, run:
ls -ld /var/lib/mysql
The output should show the MySQL user and group ownership (usually ‘mysql’) and the correct permissions (usually drwxr-xr-x). If you need to change the ownership, use the chown command:
sudo chown -R mysql:mysql /var/lib/mysql
Step 4: Restart MySQL service
After freeing up disk space and ensuring correct permissions, restart the MySQL service:
sudo service mysql restart
Now, try creating the database again.
mysql> CREATE DATABASE newdbname; Query OK, 1 row affected (0.00 sec)
Programs Mentioned:
- MySQL – An open-source relational database management system used for managing databases and organizing data.
Conclusion
By following this guide, you should have successfully resolved the MySQL error “Can’t create database ‘newdbname’ (errno: 28)” by checking available disk space, freeing up disk space, and ensuring the correct permissions for the MySQL data directory. Always monitor your server’s disk usage and perform regular maintenance to avoid running into similar issues in the future.
If you have any questions, comments, or suggestions for improvements, please feel free to share your thoughts. Your feedback helps us provide the most accurate and useful information possible.