phpmyadmin mysql error 1005 cant create a table

261 Views Asked by At

Recently I was looking a database on phpmyadmin, and I had a table called momios_partido which had the following columns:

- mopa_id int(11) **(Primary key)**
- par_id int(11) **(Foreign key references a table called "partido")**
- tiju_id int(11) **(Foreign key references a table called "tipo_jugada")**
- mopa_valor int(11) **(This one is to assign a value)**

Well, I was making a select * from that table and the mysqld.exe process stopped and when I restarted it, the table doesn't appear more, so I assumed that the error cleared the table, I tried create the table again and I can't create it.

I was looking for the reason, so i applied the following commands without result:

- flush table momios_partido
- Drop table if exists momios_partido
- Clear the .frm files in mysql/data/mydatabase:

Image

And I still having the same error, so I created another table to see what happened that table I called momiospartido without the primary key mopa_id (that means I created with par_id, tiju_id and mopa_valor columns)

So the phpmyadmin allows create it, after that, I added the foreign keys to par_id and tiju_id and it works perfect, later when I added the field mopa_id and I set that field like primary key, the error appear again (mysqld.exe has stopped and after the restart it doesn't appear more)

So I can't create a new table with those names: "momios_partido","momiospartido" indistinctly of the columns that I add to the table.

The foreign keys had the same datatype (int(11)),the same engine INNODB and im creating it with the phpmyadmin interface without sql commands.

So what am I doing wrong?.

Hope can help me, thanks so much, greetings.

1

There are 1 best solutions below

6
Hasitha Amarathunga On

Try this :

CREATE TABLE momios_partido 
(
    mopa_id int(11) Primary key,
    par_id int(11),
    tiju_id int(11),
    mopa_valor int(11),
    FOREIGN KEY (par_id) REFERENCES partido(par_id),
    FOREIGN KEY (tiju_id) REFERENCES tipo_jugada(tiju_id)
)engine = innodb;