MySQL在Windows上测试完成后,在Linux上插入了奇怪的错误

时间:2018-04-10 04:25:07

标签: mysql linux

所以我最初在Windows上的PHPMyAdmin中做了所有这些并且它们都运行良好,但是现在我已经将.sql文件移到Linux上与PHPMyAdmin一起使用了,我得到了1459个错误(所有这些都源自同一个问题,我相信)

无论如何,这里的代码是:

DROP TABLE IF EXISTS person;
CREATE TABLE IF NOT EXISTS person
(
person_id INT(9) NOT NULL,
person_first_name CHAR(30) NOT NULL,
person_last_name CHAR(30) NOT NULL,
person_phone_number INT(11) NOT NULL,
person_birth_date DATE NOT NULL,
person_is_employee BOOLEAN NOT NULL,
person_is_patient BOOLEAN NOT NULL,
PRIMARY KEY (person_id)
);

INSERT INTO person
(person_id, person_first_name, person_last_name, person_phone_number, person_birth_date, person_is_employee, person_is_patient) 
VALUES
(1, 'Dan', 'Letersky', 381214214, STR_TO_DATE('1/9/1988', '%d/%m/%Y'), FALSE, TRUE),
(2, 'Dave', 'Altvater', 541907901, STR_TO_DATE('2/9/1988', '%d/%m/%Y'), FALSE, FALSE),
(3, 'Doug', 'Aiken', 661324324, STR_TO_DATE('3/9/1988', '%d/%m/%Y'), TRUE, TRUE),
(4, 'Dean', 'Marra', 701542542, STR_TO_DATE('4/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(5, 'Alice', 'Altvater', 541907901, STR_TO_DATE('5/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(6, 'Andy', 'Letersky', 681214214, STR_TO_DATE('6/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(7, 'Andrew', 'Aiken', 661324324, STR_TO_DATE('7/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(21, 'sDan', 'sLetersky', 2381214214, STR_TO_DATE('8/9/1988', '%d/%m/%Y'), FALSE, TRUE),
(22, 'sDave', 'sAltvater', 2541907901, STR_TO_DATE('9/9/1988', '%d/%m/%Y'), FALSE, FALSE),
(23, 'sDoug', 'sAiken', 2661324324, STR_TO_DATE('10/9/1988', '%d/%m/%Y'), TRUE, TRUE),
(24, 'sDean', 'sMarra', 2701542542, STR_TO_DATE('11/9/1988', '%d/%m/%Y'), TRUE, FALSE),

我收到了这些错误:

enter image description here

任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:4)

从错误来看,这可能是引用问题。 Windows和Linux以不同方式管理报价。请检查sql文件引号并更正它们,它应该可以工作。

将person_phone_number字段更改为VARCHAR(11)。电话没有超出范围的价值。

DROP TABLE IF EXISTS person;
CREATE TABLE IF NOT EXISTS person
(
person_id INT(9) NOT NULL,
person_first_name CHAR(30) NOT NULL,
person_last_name CHAR(30) NOT NULL,
person_phone_number VARCHAR(11) NOT NULL,
person_birth_date DATE NOT NULL,
person_is_employee BOOLEAN NOT NULL,
person_is_patient BOOLEAN NOT NULL,
PRIMARY KEY (person_id)
);

INSERT INTO person
(person_id, person_first_name, person_last_name, person_phone_number, person_birth_date, person_is_employee, person_is_patient) 
VALUES
(1, 'Dan', 'Letersky', 381214214, STR_TO_DATE('1,9,1988', '%d,%m,%Y'), FALSE, TRUE),
(2, 'Dave', 'Altvater', 541907901, STR_TO_DATE('2,9,1988', '%d,%m,%Y'), FALSE, FALSE),
(3, 'Doug', 'Aiken', 661324324, STR_TO_DATE('3/9/1988', '%d/%m/%Y'), TRUE, TRUE),
(4, 'Dean', 'Marra', 701542542, STR_TO_DATE('4/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(5, 'Alice', 'Altvater', 541907901, STR_TO_DATE('5/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(6, 'Andy', 'Letersky', 681214214, STR_TO_DATE('6/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(7, 'Andrew', 'Aiken', 661324324, STR_TO_DATE('7/9/1988', '%d/%m/%Y'), TRUE, FALSE),
(21, 'sDan', 'sLetersky', 2381214214, STR_TO_DATE('8/9/1988', '%d/%m/%Y'), FALSE, TRUE),
(22, 'sDave', 'sAltvater', 2541907901, STR_TO_DATE('9/9/1988', '%d/%m/%Y'), FALSE, FALSE),
(23, 'sDoug', 'sAiken', 2661324324, STR_TO_DATE('10/9/1988', '%d/%m/%Y'), TRUE, TRUE),
(24, 'sDean', 'sMarra', 2701542542, STR_TO_DATE('11/9/1988', '%d/%m/%Y'), TRUE, FALSE)

答案 1 :(得分:0)

你可以检查一下它是否有效....它没有你提到的错误就为我跑了

  

DROP TABLE IF EXISTS person;创建表如果不是EXISTS人(   person_id INT(9)NOT NULL,person_first_name CHAR(30)NOT NULL,   person_last_name CHAR(30)NOT NULL,person_phone_number INT(11)NOT   NULL,person_birth_date DATE NOT NULL,person_is_employee BOOLEAN NOT   NULL,person_is_patient BOOLEAN NOT NULL,PRIMARY KEY(person_id));

     

INSERT INTO person(person_id,person_first_name,person_last_name,   person_phone_number,person_birth_date,person_is_employee,   person_is_patient)VALUES(1,' Dan',' Letersky',381214214,   STR_TO_DATE(' 1/9/198','%d /%m /%Y'),FALSE,TRUE),(2,' Dave',   ' Altvater',541907901,STR_TO_DATE(' 2/9 / 1988','%d /%m /%Y'),FALSE,   FALSE),(3,' Doug',' Aiken',661324324,STR_TO_DATE(' 3/9/1988',   '%d /%m /%Y'),TRUE,TRUE),(4,' Dean',' Marra',701542542,   STR_TO_DATE(' 4/9 / 1988','%d /%m /%Y'),TRUE,FALSE),(5,' Alice',   ' Altvater',541907901,STR_TO_DATE(' 5/9 / 1988','%d /%m /%Y'),TRUE,   FALSE),(6,' Andy',' Letersky',681214214,STR_TO_DATE(' 6/9 / 1988',   '%d /%m /%Y'),TRUE,FALSE),(7,' Andrew',' Aiken',661324324,   STR_TO_DATE(' 7/9 / 1988','%d /%m /%Y'),TRUE,FALSE),(21,' sDan',   ' sLetersky',2381214214,STR_TO_DATE(' 8/9 / 1988','%d /%m /%Y'),FALSE,   TRUE),(22,' sDave' sAltvater',2541907901,STR_TO_DATE(' 9/9/1988',   '%d /%m /%Y'),FALSE,FALSE),(23,' sDoug',' sAiken',2661324324,   STR_TO_DATE(' 10/9 / 1988','%d /%m /%Y'),TRUE,TRUE),(24,' sDean',   ' sMarra',2701542542,STR_TO_DATE(' 11/9 / 1988','%d /%m /%Y'),TRUE,   FALSE)

`