I read many articles about adding it, but I'm not encouraged to use it yet. People says that Drupal doesn't add this user because MySQL Auto-increment starts at 1. So, about adding uid=0, is it a good practice? Is it widely used? What possible problems could I have with it? Thanks. :)
-
1I'm a little baffled: A drupal site will be completely broken if you don't have a "0" row in the users table. UID 0 is the anonymous user. So please follow up on what you're asking.– rfayMay 3, 2011 at 16:46
-
Hello manoelhc, and welcome on Drupal Answers. As far as I remember, the user table does contain a row with uid equal to zero.– apaderno ♦May 3, 2011 at 16:48
-
Sorry Guys, The base version here doesn't has the uid=0 for some reasons and I confused with Drupal official releases.– manoelhcMay 3, 2011 at 17:20
1 Answer
Drupal does come with a row with uid=0 by default.
Some backup tools (notoriously some versions of PHPMyAdmin) are unable to deal with that, so you will lose this row when restoring from backup.
The easiest way to get back the missing row is to issue this query (for example in PHPMyAdmin):
UPDATE users SET uid = uid - uid WHERE name = ''
-
It's not a fault of the backup tools - inserting a value of 0 into an auto-incrementing integer field in a MyISAM (and probably most other DB table formats) table will result in that field being set to the next value in the auto-increment list... MyISAM starts counting from 1 (hence the need to insert and then update). All the backup tools do is create INSERT queries to rebuild the data as is.– HorusKolMay 4, 2011 at 23:52
-
2It's definitely the fault of the backup tool. They are supposed to put MySQL in NO_AUTO_VALUE_ON_ZERO mode (MySQL's own mysqldump does that). If your backup tool is not able to restore exactly the same thing that got backed-up, you can hardly call it a backup tool. May 5, 2011 at 7:00
-
2Other then that, having an hardcoded "0" in an autoincrement column is definitely not the smartest choice. There is some work to change this in: drupal.org/node/350407 May 5, 2011 at 7:01
-
Probably is a backup tool removed the uid=0. Drupal, by default, use id=0. So thank you guy so much!– manoelhcMay 5, 2011 at 12:01
-
@DamienTournod yeah, the uid=0 was an interesting design choice... interesting to read that discussion for uid=NULL– HorusKolMay 5, 2011 at 23:11