I am a Permanent Member (or Community Ambassador) of the Drupal Association.Use these two SQL commands to repair your Drupal 6 site to restore the anonymous user database record:
INSERT INTO users (name, mail) VALUES ('', '');
UPDATE users SET uid=0 WHERE name='';The symptoms you'll see that tip you off that this is needed:
SELECT * FROM users WHERE uid=0; returns zero rows.The reason you have to INSERT INTO and then UPDATE is because of the autoincrement functionality on the users table. If you don't believe me, try this experiment:
# delete user 0
mysql> DELETE FROM users WHERE uid=0;
Query OK, 1 row affected (0.00 sec)
# try to restore user 0 directly
mysql> INSERT INTO users (uid, name, mail) VALUES (0, '', '');
Query OK, 1 row affected (0.00 sec)
# see that it didn't work
mysql> SELECT uid FROM users WHERE name='';
+-------+
| uid |
+-------+
| 19611 |
+-------+
Note that if you get a Duplicate entry error like the following, you need to delete the spurious rows prior to running the corrective queries I list at the beginning of the post.
# If you see this....
mysql> INSERT INTO users (name, mail) VALUES ('', '');
ERROR 1062 (23000): Duplicate entry '' for key 2
# Do this.
mysql> DELETE FROM users WHERE name='';
Comments
thanks for documenting this!
I had some VBO views that were returning 0 records even though I knew that there were nodes in the database that matched.
Low and behold...my other VBO for deleting users allowed me to delete UID 0 which caused the problem. And when it happened I knew to come here to find the queries to set me straight. Thanks, Rob!
Post new comment