Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie needs advice #1062 - Duplicate entry '' for key 1 1

Status
Not open for further replies.

gosuc2000

Technical User
Jun 2, 2004
59
DE
Hello list,

I'm new to MySql, and have MySQL 4.0.18 installed on my Linux-box.
I have created a new database (sample_db)with
"mysqladmin -p create sample_db"
After that I wanted to add the corresponding values for
that database and its user into the mysql database.
So I typed
mysql> use mysql;

The host-tablestructure looks like this:
(hosttable privileges):

FIELD TYPE ATTRIBUTES
----------------------------------------------
Host char(60) Binary
Db char(64) Binary
Select_priv enum('N','Y')
Insert_priv enum('N','Y')
Update_priv enum('N','Y')
Delete_priv enum('N','Y')
Create_priv enum('N','Y')
Drop_priv enum('N','Y')
Grant_priv enum('N','Y')
References_priv enum('N','Y')
Index_priv enum('N','Y')
Alter_priv enum('N','Y')
Create_tmp_table_priv enum('N','Y')
Lock_tables_priv enum('N','Y')

Then I typed:
insert into host values('localhost','sample_db','Y','Y','Y','Y','Y'
,'Y','Y','Y','Y','Y','Y','Y');

and got the response:
ERROR 1062: Duplicate entry 'localhost-sample_db' for key 1

Like I said, i'm new to MySQL and can't figure out what is wrong with the insert-instruction.

Any help to show me what's wrong here is apreciated.

Thanks in advance,

Fred
 
what's wrong is that you attempted to insert a value into a column defined as unique, and it already had the value that you were trying to insert

r937.com | rudy.ca
 
Hello,
thank you for that tip.You're right.I removed the former value and it works now.
Again, thanks a lot for your help.

Regards,

Fred
 
Hi,

I'm having the same problem, although i'm not trying to add a duplicate value, and the column is not defined as unique - the field is a char of length 35 and this is not changeable - i also cannot and an extra column to the table to auto-increment (thought about that!)

Any ideas why i am not able to insert a new record into this table?? or where i can start looking to solve it :(
 
nickyjay, please do not append a new problem onto an old thread

if you decide to post your new problem, please be sure to include relevant information such as what version you're on, what the SHOW CREATE TABLE reveals, the INSERT statement that didn't work, and the error message or other indicator you got that the insert didn't work

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top