Home:ALL Converter>MYSQL : MySql Import failed error no : 150

MYSQL : MySql Import failed error no : 150

Ask Time:2013-03-28T02:15:47         Author:kannanrbk

Json Formatter

I have two tables , I am exporting this two table schema and renamed it. Again I am importing the same into it.

Script

mysql -uroot  audit --add-drop-table=false --no-data SignInAudit UAAudit > out.sql
mysql -uroot audit -e "RENAME TABLE SignInAudit TO SignInAudit1"
mysql -uroot audit -e "RENAME TABLE UAAudit TO UAAudit1"
#Create the table again.
mysql -uroot audit < out.sql

Schema

CREATE TABLE `SignInAudit` (
  `SID` int(11) NOT NULL,
  `Uname` varchar(100) DEFAULT NULL,
  `IP` varchar(255) DEFAULT NULL,
  `LOGIN_TIME` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`SID`)
) ENGINE=InnoDB 

CREATE TABLE `UAAudit` (
  `SID` int(11) NOT NULL,
  `UserAgent` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`SID`),
  CONSTRAINT `UAAudit_ibfk_1` FOREIGN KEY (`SID`) REFERENCES `SignInAudit` (`SID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

I got this error ERROR 1005 (HY000). It may be due to "UAAudit" is referencing "SignInAudit". But , I am exporting in correcting order (SignInAudit , UAAudit).

How can I import the sql?

Author:kannanrbk,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15666383/mysql-mysql-import-failed-error-no-150
yy