WordPress media upload issue could not insert attachment into the database

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.