Last updated March 14, 2014. Created on February 4, 2012.
Edited by batigolix, vincent sg. Log in to edit this page.


Some of the fields in the database lost their default values.

Drupal produces errors like

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'users' doesn't have a default value: INSERT INTO {node} (vid, type, language, title, uid, status, created, changed, promote, sticky) VALUES ...

In this case the node table has a users column that has no default value. In Drupal 7 this column does not exist by default but it may be a left over from several upgrades (Drupal 4 --> Drupal7).


Fast method

Use a tool like phpmyadmin or the drush command sqlq to run a query that assigns a default value to the column in question.

In the case described above the sql to fix the problem is:


Manual Method (45 mins to 1.5 hr)

1. Put your site to offline mode.

2. Backup all your databases and files (Important).

3. Install Drupal (same version) to another fresh database. Do NOT uninstall your existing site.

4. Enable the same modules (same version). Run update.php.

5. Open phpMyAdmin and select the new Drupal database.

6. Open phpMyAdmin and select the faulty Drupal database.

7. Select a table (same name in the new database and faulty database).

8. Select 'Structure' tab (on both sides).

9. Compare the 'Name' and 'Default' columns. Pay attention to blanks (in the new database) and 'None' (in the faulty database).

10. If you see any difference in 'Default' values, select 'Change' (Pencil icon) on the faulty database. If no difference, proceed to step 7 or 14.

11. Under 'Default', select 'As defined:'.

12. Select 'Save'.

13. Repeat steps 9 to 12 until the 'Default' values are the same.

14. Repeat steps 7 to 13 until all the 'Default' values in all the tables are the same.

15. Put your site to online mode.

16. Make sure that your site is functioning normally.

17. Remove the installation done in step 3.

Looking for support? Visit the forums, or join #drupal-support in IRC.


fleuv’s picture

For people working with hook_schema and are dealing with the same problem.

Non of these methods will work. You should make sure that you've added all table columns to your hook_schema fields. After that you should clean all cache! This problem occurred for me after adding a new column in phpmyadmin manually.