Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 无法保存最近的表!phpMyAdmin#1062-重复条目';根';对于键';初级';_Mysql_Mysql Workbench - Fatal编程技术网

Mysql 无法保存最近的表!phpMyAdmin#1062-重复条目';根';对于键';初级';

Mysql 无法保存最近的表!phpMyAdmin#1062-重复条目';根';对于键';初级';,mysql,mysql-workbench,Mysql,Mysql Workbench,所以我在workbench中制作了一个EER图: 然后我使用forward engineer创建数据库(还尝试了脚本复制方法) 这一切似乎都很好,但当我试图查看任何表时,我总是在phpMyAdmin中遇到这个错误: 我尝试导出数据库并导入,但没有改变任何东西 数据库备份: -- phpMyAdmin SQL Dump -- version 4.5.0.2 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time:

所以我在workbench中制作了一个EER图:

然后我使用forward engineer创建数据库(还尝试了脚本复制方法)

这一切似乎都很好,但当我试图查看任何表时,我总是在phpMyAdmin中遇到这个错误:

我尝试导出数据库并导入,但没有改变任何东西

数据库备份:

-- phpMyAdmin SQL Dump
-- version 4.5.0.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Dec 03, 2015 at 05:45 AM
-- Server version: 10.0.17-MariaDB
-- PHP Version: 5.6.14

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


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

--
-- Database: `mydb`
--

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

--
-- Table structure for table `tblattendees`
--

CREATE TABLE `tblattendees` (
  `AttendeeID` int(10) NOT NULL,
  `FirstName` varchar(45) DEFAULT NULL,
  `LastName` varchar(45) DEFAULT NULL,
  `Title` varchar(45) DEFAULT NULL,
  `CompanyName` varchar(45) DEFAULT NULL,
  `Address` varchar(200) DEFAULT NULL,
  `Suburb` varchar(45) DEFAULT NULL,
  `State` varchar(3) DEFAULT NULL,
  `Country` varchar(45) DEFAULT NULL,
  `Postcode` varchar(10) DEFAULT NULL,
  `Phone` varchar(15) DEFAULT NULL,
  `Fax` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tblattendees`
--

INSERT INTO `tblattendees` (`AttendeeID`, `FirstName`, `LastName`, `Title`, `CompanyName`, `Address`, `Suburb`, `State`, `Country`, `Postcode`, `Phone`, `Fax`) VALUES
(1, 'Stuart', 'Masia', 'Mr', 'M''Fees at Glebe', '234 Regent Drive', 'GLEBE', 'NSW', 'Australia', '2037', '02 9660 8856', '02 9660 8857'),
(2, 'Annie', 'Walker', 'Ms', 'Tuggeranon Eat House', '76 View Street', 'TUGGERANON', 'ACT', 'Australia', '0269', '06 4670 0023', '06 4670 0024'),
(3, 'Robert', 'Argyle', 'Mr', 'M''Fees Leichhardt', '19 Beauty Place', 'LEICHHARDT', 'NSW', 'Australia', '2040', '02 9662 3432', '02 9662 3433'),
(4, 'Hilde', 'Sorenson', 'Ms', 'Chatswood Deluxe', '301 Chalmers Street', 'CHATSWOOD', 'NSW', 'Australia', '2057', '02 9416 9092', '02 9416 9092'),
(5, 'Thomas', 'Williams', 'Mr', 'Rocklea Best Serves', '98 Argent Street', 'ROCKLEA', 'QLD', 'Australia', '4106', '07 6789 5693', '07 6789 5693'),
(6, 'Gary', 'Zheng', 'Mr', 'M''Fees Hazelvale', '467 The Esplanade', 'HAZELVALE', 'WA', 'Australia', '6333', '09 4563 6378', '09 4563 6379'),
(7, 'Natalie', 'Mylonas', 'Ms', 'M''Fees Picton', '6 Travers Lane', 'PICTON', 'NSW', 'Australia', '2571', '02 9566 4887', '02 9566 4887'),
(8, 'Manny', 'Reeves', 'Ms', 'M''Fees Lillyvale', '7/45 Market Street', 'LILYDALE', 'NSW', 'Australia', '2460', '02 9708 6541', '02 9708 6541'),
(9, 'Michael', 'Su', 'Mr', 'M''Fees Camden', '43 Lilly Pilly Avenue', 'CAMDEN', 'NSW', 'Australia', '2570', '02 9630 5851', '02 9630 5851'),
(10, 'Allan', 'Markson', 'Mr', 'M''Fees Brakendale', '4 Robertson Street', 'BRACKENDALE', 'NSW', 'Australia', '2127', '02 9720 7323', '02 9720 7323'),
(11, 'Kylie', 'Lee', 'Ms', 'Puchbowl Eat House', '22/118 Western Gardens', 'PUNCHBOWL', 'NSW', 'Australia', '2565', '02 9672 6574', '02 9672 6555'),
(12, 'May', 'Tucker', 'Ms', 'M''Fees Ruse', '37 Tulip Crescent', 'RUSE', 'NSW', 'Australia', '2560', '02 9860 7465', '02 9860 7465'),
(13, 'Greg', 'Higgins', 'Mr', 'M''Fees SA', '61 Sunlight Avenue', 'MILLICENT', 'SA', 'Australia', '5280', '08 7684 3324', '08 7684 3324'),
(15, 'Janine', 'Khoury', 'Ms', 'M''Fees Kellyvile', '55 Jamberro Street', 'KELLYVILLE', 'NSW', 'Australia', '2155', '02 9590 4874', '02 9590 4874'),
(16, 'David', 'Jones', 'Mr', 'M''Fees Western', 'P.O. Box 234', 'PARRAMATTA', 'NSW', 'Australia', '2150', '02 9768 7754', '02 9768 7755'),
(17, 'Tony', 'Marchant', '', NULL, '3 Grose St', 'Richmond', 'NSW', 'Australia', '2753', '02 45784455', ''),
(18, 'Kerry', 'Badopolas', 'Mr', NULL, '72 Kilcare Road', 'Blayney', 'NSW', 'Australia', '2799', '34343434343', ''),
(19, 'Rodney', 'Roberts', 'Mr', NULL, '4 Grose St', 'Richmond', 'NSW', 'Australia', '2753', '0299458888', ''),
(20, 'Charlie', 'Brown', 'Dr', NULL, 'Hight Street', 'Lithgow', 'NSW', 'Australia', '2794', '0268239000', ''),
(21, 'Bill', 'Hermatige', 'Pastor', 'Heavens Helpers', 'Hope Street', 'Outlooking', 'SA', 'Australia', '3345', '0398983343', ''),
(22, 'Clancy', 'Snow', 'Mr', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

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

--
-- Table structure for table `tblevents`
--

CREATE TABLE `tblevents` (
  `EventID` int(10) NOT NULL,
  `EventName` varchar(50) DEFAULT NULL,
  `Location` varchar(200) DEFAULT NULL,
  `StartDate` datetime DEFAULT NULL,
  `EndDate` datetime DEFAULT NULL,
  `Confirmed` tinyint(1) DEFAULT NULL,
  `EventDesc` varchar(1000) DEFAULT NULL,
  `EventFee` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tblevents`
--

INSERT INTO `tblevents` (`EventID`, `EventName`, `Location`, `StartDate`, `EndDate`, `Confirmed`, `EventDesc`, `EventFee`) VALUES
(1, 'McFees Asia-Pacific Zone Marketing Meeting', 'The Westin Sydney', '2005-06-26 00:00:00', '2005-06-30 00:00:00', 1, 'McFees annual conference', 350),
(2, 'Jones Insurance', 'Sheriden on the Park', '2005-08-01 00:00:00', '2005-08-03 00:00:00', 1, 'Jones Insurance half yealy Meeting', 320),
(3, 'Innovations Christmas Party', 'Captain Cook Cruises', '2005-12-20 00:00:00', '2005-12-20 00:00:00', 1, 'Work Christmas Party', 100),
(4, 'Innovations Christmas Party', 'Captain Cook Cruises', '2006-12-20 00:00:00', '2006-12-20 00:00:00', 0, 'Work Christmas Party', 200),
(5, 'Jones Insurance', 'Sebel Townhouse', '2006-01-25 00:00:00', '2006-01-25 00:00:00', 1, 'Weekend Escape', 650);

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

--
-- Table structure for table `tblregistration`
--

CREATE TABLE `tblregistration` (
  `RegistrationID` int(10) NOT NULL,
  `AttendeeID` int(10) NOT NULL,
  `EventID` int(10) NOT NULL,
  `RegistrationDate` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'This is the date and time the attendee registered for the event, or made the registration.',
  `RegistrationPaid` double DEFAULT NULL COMMENT 'This is the amount paid for registration for an event.'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tblregistration`
--

INSERT INTO `tblregistration` (`RegistrationID`, `AttendeeID`, `EventID`, `RegistrationDate`, `RegistrationPaid`) VALUES
(1, 1, 1, '2005-01-30 00:00:00', 350),
(2, 5, 2, '2005-02-02 00:00:00', 300),
(3, 1, 2, '2005-01-30 00:00:00', 320),
(4, 1, 3, '2004-12-15 00:00:00', 50),
(5, 3, 1, '2005-01-30 00:00:00', 150),
(6, 10, 2, '2004-12-12 00:00:00', 150),
(7, 4, 3, '2005-02-25 00:00:00', 100),
(8, 5, 3, '2004-08-17 19:29:10', 50),
(12, 15, 3, '2004-08-17 20:06:14', 100),
(13, 7, 3, '2004-08-17 21:12:41', 0),
(14, 16, 3, '2004-08-17 21:35:51', 0),
(15, 6, 3, '2004-08-17 23:03:07', 0),
(16, 12, 2, '2004-08-17 23:28:48', 0),
(17, 7, 2, '2004-08-17 23:41:50', 0),
(18, 2, 3, '2004-08-18 00:20:17', 0),
(19, 9, 2, '2004-08-18 00:21:20', 0),
(20, 8, 3, '2004-08-18 00:23:52', 0),
(21, 17, 3, '2004-08-18 09:28:08', 0),
(22, 13, 3, '2004-08-18 09:34:41', 0),
(23, 2, 1, '2004-08-23 10:43:38', 0),
(25, 11, 3, '2004-08-23 11:26:06', 100),
(26, 18, 3, '2004-08-23 11:26:27', 0),
(27, 19, 2, '2004-08-23 11:26:36', 0),
(28, 11, 2, '2004-08-23 12:09:41', 0),
(29, 20, 1, '2004-08-23 12:43:12', 0),
(30, 17, 1, '2004-08-23 22:10:13', 100),
(32, 21, 1, '2004-08-23 22:24:13', 350),
(33, 19, 3, '2004-08-23 22:31:11', 0);

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

--
-- Table structure for table `tblstaff`
--

CREATE TABLE `tblstaff` (
  `StaffID` int(10) NOT NULL,
  `FirstName` varchar(45) NOT NULL,
  `LastName` varchar(45) NOT NULL,
  `Phone` varchar(15) DEFAULT NULL,
  `Mobile` varchar(30) DEFAULT NULL,
  `Email` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tblstaff`
--

INSERT INTO `tblstaff` (`StaffID`, `FirstName`, `LastName`, `Phone`, `Mobile`, `Email`) VALUES
(1, 'Yin', 'Nguyen', '0297310273', '0415760088', 'johnsmirth@net.org'),
(2, 'Sandra', 'Jackson', '023204929', '041576089', 'CRAZYLADY@lady.org'),
(3, '', '', NULL, NULL, NULL),
(4, 'Stephen', 'Michaels', '0291283128', '0418586383', 'Stephanman@gmail.com'),
(5, 'Marie', 'Kukedis', NULL, '04156778', NULL),
(6, 'Robert', 'Maclean', NULL, NULL, NULL),
(7, 'Chantelle', 'Ross', '0297310286', '0455768904', NULL);

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

--
-- Table structure for table `tblstaff_br_tblevents`
--

CREATE TABLE `tblstaff_br_tblevents` (
  `tblstaff_StaffID` int(10) NOT NULL,
  `tblevents_EventID` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tblstaff_br_tblevents`
--

INSERT INTO `tblstaff_br_tblevents` (`tblstaff_StaffID`, `tblevents_EventID`) VALUES
(1, 1),
(1, 2),
(1, 5),
(2, 3),
(2, 4),
(2, 5);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tblattendees`
--
ALTER TABLE `tblattendees`
  ADD PRIMARY KEY (`AttendeeID`);

--
-- Indexes for table `tblevents`
--
ALTER TABLE `tblevents`
  ADD PRIMARY KEY (`EventID`);

--
-- Indexes for table `tblregistration`
--
ALTER TABLE `tblregistration`
  ADD PRIMARY KEY (`RegistrationID`,`EventID`,`AttendeeID`),
  ADD KEY `fk_tblregistrations_tblattendees1_idx` (`AttendeeID`),
  ADD KEY `fk_tblregistrations_tblevents1_idx` (`EventID`);

--
-- Indexes for table `tblstaff`
--
ALTER TABLE `tblstaff`
  ADD PRIMARY KEY (`StaffID`);

--
-- Indexes for table `tblstaff_br_tblevents`
--
ALTER TABLE `tblstaff_br_tblevents`
  ADD PRIMARY KEY (`tblstaff_StaffID`,`tblevents_EventID`),
  ADD KEY `fk_br_EventID_idx` (`tblevents_EventID`),
  ADD KEY `fk_br_StaffID_idx` (`tblstaff_StaffID`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tblattendees`
--
ALTER TABLE `tblattendees`
  MODIFY `AttendeeID` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `tblevents`
--
ALTER TABLE `tblevents`
  MODIFY `EventID` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `tblregistration`
--
ALTER TABLE `tblregistration`
  MODIFY `RegistrationID` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34;
--
-- AUTO_INCREMENT for table `tblstaff`
--
ALTER TABLE `tblstaff`
  MODIFY `StaffID` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `tblregistration`
--
ALTER TABLE `tblregistration`
  ADD CONSTRAINT `fk_tblregistrations_tblattendees_AttendeeID` FOREIGN KEY (`AttendeeID`) REFERENCES `tblattendees` (`AttendeeID`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_tblregistrations_tblevents_EventID` FOREIGN KEY (`EventID`) REFERENCES `tblevents` (`EventID`) ON UPDATE CASCADE;

--
-- Constraints for table `tblstaff_br_tblevents`
--
ALTER TABLE `tblstaff_br_tblevents`
  ADD CONSTRAINT `fk_tblstaff_br_tblevents_EventID` FOREIGN KEY (`tblevents_EventID`) REFERENCES `tblevents` (`EventID`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_tblstaff_br_tblevents_StaffID` FOREIGN KEY (`tblstaff_StaffID`) REFERENCES `tblstaff` (`StaffID`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!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 */;

任何帮助都将不胜感激

因此我重新启动了计算机,重新启动了以管理员身份运行的xampp,安装了服务并再次检查了phpMyAdmin,现在错误消失了


奇怪的是,这个错误只显示在使用mysql workbench脚本创建的数据库中,而不是其他数据库中。

为什么物理表中没有主键?有主键,但它在代码末尾添加了主键,这很奇怪。更改表
tblstaff\u br\u tblevents
添加主键(
tblstaff\u StaffID
tblevents\u EventID
),添加键
fk\u br\u EventID\u idx
tblevents\u EventID
),添加键
fk\u br\u StaffID\u idx
tblstaffid
);