为什么我无法在PHPMyAdmin上插入用户?

时间:2017-09-07 17:05:54

标签: php mysql phpmyadmin

我遵循本教程:https://www.youtube.com/watch?v=T9X5e_yjQB8&list=PLAkMqlQoeMeiwvNWpe3mhgQxAa1jiGwmt&index=22

我创建了一个"页面"表,"用户"一个网站的表。当我尝试在users表中插入多个用户时,PHPMyAdmin会抛出此错误:1062重复输入' 0'关键'主要'。

我试图按照MySQL 1062 - Duplicate entry '0' for key 'PRIMARY'获取约束,但它没有显示出来。

我一直在阅读外键和限制因素,但我不明白为什么会收到此错误,但教程并没有。我该如何解决这个问题?

这是我已经完成的表格的代码:

Database: `healthcms`
--

-- --------------------------------------------------------

--
-- Table structure for table `pages`
--

CREATE TABLE `pages` (
  `id` mediumint(9) NOT NULL,
  `user` mediumint(9) NOT NULL,
  `label` varchar(100) NOT NULL,
  `title` varchar(200) NOT NULL,
  `header` varchar(300) NOT NULL,
  `body` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `pages`
--

INSERT INTO `pages` (`id`, `user`, `label`, `title`, `header`, `body`) VALUES
(1, 0, 'Home', 'Home Page', 'Welcome to Health!', '\"Lorem ipsum.\"'),
(2, 0, 'About', 'About us', 'About Health', ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `pages`
--
ALTER TABLE `pages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user` (`user`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `pages`
--
ALTER TABLE `pages`
  MODIFY `id` mediumint(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


------------------------------------------------------------------------

Database: `healthcms`
--

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` mediumint(9) NOT NULL,
  `first` varchar(200) NOT NULL,
  `last` varchar(200) NOT NULL,
  `email` varchar(300) NOT NULL,
  `password` varchar(200) NOT NULL,
  `status` int(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `first`, `last`, `email`, `password`, `status`) VALUES
(0, 'John', 'Rainey', 'john@john.com', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', 1);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

谢谢!

0 个答案:

没有答案