Wordpress media upload issue could not insert attachment into the database

Could not insert attachment into the database.

When ever I try to upload new images from WordPress media it shows me above error.

Please help me why wp database shows this error.

Topic media-library uploads media Wordpress

Category Web


Auto-increment missing...

Same issue. I'd migrated the site from another server. Found that the Auto-Increment flag was missing from the wp_post table's ID column. I switched that back on and the problem resolved.

It seems like ALL the tables had lost auto-increment from their ID columns though.... headache!


Try the following solutins:

  1. First of all check your WP database size and check whether the size is full according to your hosting provider's requirement/rule.

  2. Second option, add this line into your wp-config.php:

define('WP_MEMORY_LIMIT', '256M');

Also if you have access to php.ini (or php[version number].ini) file on your server, try to add this line:

memory_limit 512M 
  1. By default, some database configs have a collation or charset that doesn't allow special character. Check whether the file name of the image you're trying to upload is having any special characters. If so, delete them and use only alphanumeric. Then retry.

  2. Also, please check your folder permission. Read more about it on https://www.wpbeginner.com/wp-tutorials/how-to-fix-image-upload-issue-in-wordpress/

Hope it helps.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.