How to Fix MySQL Database Error: Can’t create database ‘newdbname’ (errno: 28)

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).

See also  How to Update CentOS 6.4 System using 'yum update'

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:

  1. Delete unnecessary files and directories.
  2. Remove or archive old logs.
  3. Clear cache or temporary files.
  4. Uninstall unused software packages.
  5. 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.
See also  How to List Available Apache httpd Web Server Package and Info on CentOS 6.2

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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *