Archived

This topic is now archived and is closed to further replies.

MYSql Primary keys?

This topic is 5306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to write my own database for secure login, so I downloaded a copy of the SQL control center. I made a table with Username and password fields, and then I noticed this button at the top, called ''add primary key''. Would anyone mind explaining what a primary key is? And what kind of practical uses it serves? Would it be useful for writing a login page using SQL and php? Thanks.

Share this post


Link to post
Share on other sites
It is a unique, not null index. For instance, I may want to assign an id to every row in a table, and I want to be able to identify seperate rows by this id. I might make the id use a primary key to ensure that it is seperate from all other rows in the table.

It is not some sort of encryption scheme.

It is probably not necessary for writing a login page using php/sql; just make usernames unique.

Share this post


Link to post
Share on other sites
Another question.


I'm trying to connect to mysql through dreamweaver, but when I go to select my data base, dreamweaver gives me this error.


1045 Access denied for user: 'testdb@localhost' (Using password: YES)


I made the user in the control center, and I specified the same username and password to dreamweaver. O__o

When I use the username and login that WinMySQLAdmin 1.4 specifies in the 'my.ini setup' tab however, it loads the list of databases just fine.

/me thinks I'm not creating users properly?


[edited by - raymondo on June 4, 2003 10:37:22 PM]

Share this post


Link to post
Share on other sites
Well, I do my web design/layout/html/css/javascript with dreamweaver, because its fast, but I do my php/sql programming by hand, because 1.) I have more control, and 2.) I can''t get it to integrate with Dreamweaver properly.

Share this post


Link to post
Share on other sites
Try it without the password. That''s a ''feature'' of the windows version. Immediately after installation you have to run the mysql client from the command line to initially set a root password. If you don''t, then using a password will fail everytime you try to access the server. It''s actually in the documentation (or a readme maybe). At any rate, if you are using it locally there''s no need to worry about it unless you are storing sensitive data and sharing your box with several people Just login without a password.

Share this post


Link to post
Share on other sites
A primary key is a chosen candidate key that uniquely selects one row (tuple). A candidate key is a key that can select one row with so few attributes as possible.

Share this post


Link to post
Share on other sites