Click to See Complete Forum and Search --> : [RESOLVED] MySQL n00b needs help with db setup
WolfShade
12-23-2009, 02:34 PM
Hello, everyone.
I am completely unfamiliar with MySQL and am attempting to set up a MySQL database on my laptop so I may learn MySQL and PHP.
For learning purposes, I have installed MySQL and have it set up, but am running into a problem. For the practice database, I have created a table for users. I thought I had it set so that the userID is a PK and AutoIncrement. But when I use WorkBench to enter data manually, the userID's all appear as "0".
I am including a partial screenshot of WorkBench. Can someone please point out what I'm doing incorrectly?
Thank you,
^_^
NogDog
12-23-2009, 07:34 PM
If userID is the primary key, then MySQL should not allow more than one record to have an ID of 0, so if more than one record has it set to 0, there is definitely something odd going on. I've not really used Workbench at all, so I can't tell you if there is any special "gotcha" to be aware of in terms of usage or configuration.
Anyway, how are you inputting the records? Normally you either do not supply any value for the auto-increment PK column, or else NULL, at which point the DBMS applies the next auto-increment value. If you enter an explicit value (including 0), then it will use that for the value if it's not already in use (generating a duplicate key error if it is already used).
WolfShade
12-23-2009, 07:39 PM
userID is PK, NN, AI (as you can see in screenshot); yet when using WorkBench editor to insert data, leaving the userID blank, MySQL automatically enters "0" for userID. Every time. No auto increment.
When installing MySQL (I used an .msi to install it) should I have modified anything before clicking "Next"?
Thanks,
^_^
NogDog
12-23-2009, 08:56 PM
Could it be that it's something like in this [non-]bug report?
http://bugs.mysql.com/bug.php?id=45450
Essentially, it appears that in WB it will appear that 0 is being assinged until you actually submit the request, at which time the insert is actually performed by the DB server and the auto-incrementing is performed.
WolfShade
12-28-2009, 03:25 PM
Sorry for the delay; holidays and such.
I don't think it's like that bug report. And I've done the forward engineering thing in WB and it's keeping all the userIDs as 0.
WolfShade
12-29-2009, 07:01 PM
I discovered why. When looking at the data in WorkBench, it will always appear as if the userID's are all 0; however, when you open the Query Browser and do a SELECT of the data, it IS auto-incrementing the userID value. So I just needed to look at it in QB instead of WB.
^_^