O
O
olol7772014-01-10 02:49:30
MySQL
olol777, 2014-01-10 02:49:30

#1005 - Can't create table '' (errno: 150)

Goodnight! Faced a problem, does not load backup!
Actually the error itself:

Ошибка
SQL-запрос:

CREATE TABLE  `blogs` (

 `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
 `user_id` INT( 10 ) UNSIGNED NOT NULL ,
 `ctg_id` SMALLINT( 5 ) UNSIGNED NOT NULL ,
 `dt` DATETIME NOT NULL ,
 `title` VARCHAR( 255 ) DEFAULT NULL ,
 `content` TEXT NOT NULL ,
PRIMARY KEY (  `id` ) ,
KEY  `blogusr` (  `user_id` ) ,
CONSTRAINT  `blogusr` FOREIGN KEY (  `user_id` ) REFERENCES  `users` (  `id` ) ON DELETE CASCADE
) ENGINE = INNODB AUTO_INCREMENT =14 /*!40101 DEFAULT CHARSET=utf8 */;


#1005 - Can't create table 'test.blogs' (errno: 150)

And another half of the tables were successfully transferred, and half come out with this error.
What can be wrong???
PS I wanted to post a link to the database itself, but I don't know if this is allowed or not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Spiridonov, 2014-01-10
@olol777

If the MySQL CREATE TABLE statement throws error number 1005, and there is a reference to error number 150 in the error message line, the table creation failed because the foreign key constraints were not properly formed.
from here - www.mysql.ru/docs/man/SEC451.html

R
Rsa97, 2014-01-10
@Rsa97

Check that you have already created a table `users`, it has a field `users`.`id` INT( 10 ) UNSIGNED, this field is the primary key or an index is built on it, the database does not yet use the FK named ` user_id`, the `blogs` and `users` tables and the `blogs`.`user_id` and `users`.`id` fields have the same charset and collation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question