Cannot create a table in mysql error(150) - mysql

I want to create 3 tables called curenttasks, originaltasks and previoustasks. I make one table and copied to other two. But one table cannot create while other 2 are created successfully.
The three table are:
DROP TABLE IF EXISTS `CurrentTasks`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `CurrentTasks` (
`taskID` mediumint(9) NOT NULL AUTO_INCREMENT,
`taskName` varchar(255) NOT NULL,
`isActive` boolean DEFAULT TRUE,
`startDate` datetime NOT NULL,
`endDate` datetime NOT NULL,
`completeDate` datetime DEFAULT NULL,
`complexityID` smallint(6) NOT NULL,
`managerID` mediumint(9) NOT NULL,
`projectID` mediumint(9) NOT NULL,
`requirementName` varchar(255) NOT NULL,
`xPos` smallint(6) DEFAULT NULL,
`yPos` smallint(6) DEFAULT NULL,
`description` text NOT NULL,
`stageName` enum('Definition','Design','Development','Testing','Evaluation') NOT NULL DEFAULT 'Definition',
PRIMARY KEY (`taskID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `CurrentTasks`
--
LOCK TABLES `PreviousTasks` WRITE;
/*!40000 ALTER TABLE `PreviousTasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `PreviousTasks` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `PreviousTasks`
--
DROP TABLE IF EXISTS `PreviousTasks`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `PreviousTasks` (
`taskID` mediumint(9) NOT NULL AUTO_INCREMENT,
`taskName` varchar(255) NOT NULL,
`isActive` boolean DEFAULT TRUE,
`startDate` datetime NOT NULL,
`endDate` datetime NOT NULL,
`completeDate` datetime DEFAULT NULL,
`complexityID` smallint(6) NOT NULL,
`managerID` mediumint(9) NOT NULL,
`projectID` mediumint(9) NOT NULL,
`requirementName` varchar(255) NOT NULL,
`xPos` smallint(6) DEFAULT NULL,
`yPos` smallint(6) DEFAULT NULL,
`description` text NOT NULL,
`stageName` enum('Definition','Design','Development','Testing','Evaluation') NOT NULL DEFAULT 'Definition',
PRIMARY KEY (`taskID`),
UNIQUE KEY `uniquePreviousTasks` (`requirementName`,`projectID`,`taskName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `PreviousTasks`
--
LOCK TABLES `PreviousTasks` WRITE;
/*!40000 ALTER TABLE `PreviousTasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `PreviousTasks` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `OriginalTasks`
--
DROP TABLE IF EXISTS `OriginalTasks`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `OriginalTasks` (
`taskID` mediumint(9) NOT NULL AUTO_INCREMENT,
`taskName` varchar(255) NOT NULL,
`isActive` boolean DEFAULT TRUE,
`startDate` datetime NOT NULL,
`endDate` datetime NOT NULL,
`completeDate` datetime DEFAULT NULL,
`complexityID` smallint(6) NOT NULL,
`managerID` mediumint(9) NOT NULL,
`projectID` mediumint(9) NOT NULL,
`requirementName` varchar(255) NOT NULL,
`xPos` smallint(6) DEFAULT NULL,
`yPos` smallint(6) DEFAULT NULL,
`description` text NOT NULL,
`stageName` enum('Definition','Design','Development','Testing','Evaluation') NOT NULL DEFAULT 'Definition',
PRIMARY KEY (`taskID`),
UNIQUE KEY `uniqueOriginalTasks` (`requirementName`,`projectID`,`taskName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `OriginalTasks`
--
LOCK TABLES `OriginalTasks` WRITE;
/*!40000 ALTER TABLE `OriginalTasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `OriginalTasks` ENABLE KEYS */;
UNLOCK TABLES;
The currenttasks cannot cteate, the error is:
ERROR 1005 (HY000): Can't create table 'rem.currenttasks' (errno: 150)
I just very confused because I delete currenttasks and copied previoustasks to it, replace every previous with current, but it still cannot work.

You forgot to delete lines between 28-31. PreviousTasks table is not created yet, but those lines tries to alter table. Also same thing exist at lines 64-67.

Related

MySQL dump file has some issue with foreign key constraint. referenced column '**' in foreign key constraint '**' are incompatible

I would like to import SQL dump file, some how it's not working.
I got this error when I try to import data.
Referencing column 'originator_id' and referenced column 'name' in foreign key constraint 'fk_rails_79d8c4ccda' are incompatible.
DROP TABLE IF EXISTS `loan_fee_shares`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `loan_fee_shares` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`originator_id` varchar(255) DEFAULT NULL,
`percent` decimal(6,2) DEFAULT NULL COMMENT 'belongs to [0,1] set',
`active` tinyint(1) DEFAULT '0',
`deactivated_at` timestamp NULL DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_rails_79d8c4ccda` (`originator_id`),
CONSTRAINT `fk_rails_79d8c4ccda` FOREIGN KEY (`originator_id`) REFERENCES `originators` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
DROP TABLE IF EXISTS `originators`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `originators` (
`name` varchar(255) DEFAULT NULL,
`description` varchar(100) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`name`),
UNIQUE KEY `index_originators_on_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
I am posting this for someone who might have the same issue in the future.
Barmar has a good point. and I moved originators table to before loan_fee_shares. But I still had an issue.
and It had an issue with DEFAULT CHARSET=latin1, I had to change it to DEFAULT CHARSET=utf8. and It works.
I suggest that change all your tables to the same character set.
How to change all the tables in my database to UTF8 character set?

How to migrate MYSQL database with having different column name?

I have two database old.sql & new.sql.
I have user table named user in new.sql. and users in old.sql.
table structure for user from new.sql
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user` (
`id` int NOT NULL AUTO_INCREMENT,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`firstName` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`lastName` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`phoneNumber` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`role` enum('USER','ADMIN') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USER',
`createdOn` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
PRIMARY KEY (`id`),
UNIQUE KEY `User_email_key` (`email`),
UNIQUE KEY `User_phoneNumber_key` (`phoneNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = #saved_cs_client */;
and users from old.sql
DROP TABLE IF EXISTS `users`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT,
`roleId` int NOT NULL,
`firstName` varchar(255) DEFAULT NULL,
`lastName` varchar(255) DEFAULT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) DEFAULT NULL,
`status` tinyint(1) DEFAULT '1',
`resetPasswordExpires` datetime DEFAULT NULL,
`resetPasswordToken` varchar(255) DEFAULT NULL,
`createdAt` datetime NOT NULL,
`updatedAt` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `roleId` (`roleId`),
CONSTRAINT `Users_ibfk_1` FOREIGN KEY (`roleId`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=884 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = #saved_cs_client */;
now I want to migrate user from old database to new database.
this is only one table, we have many tables to migrate data.
how can I achieve that ?
also we have done normalization in new database like
old.sql one table separated in 2 or 3 new tables in new database.
These DBs are on the same MySQL instance.
You can use a simple script like:
INSERT INTO
user (id, email, password, firstName, lastName, phoneNumber, role, createdOn)
SELECT
id, email, password, firstName, lastName, null, IF(roleId = 1, 'ADMIN', 'USER'), created
FROM users;
Just set correct roleId for condition and remove id if you need a new one.
Tiny example of the data transferring realization with some remarks: DEMO fiddle

Problem with importing mysql workbench data

I have a table and data. When importing, automatically importing data into the user table throws a foreign key error. How do I load data into a table?
I understand that the problem is in the foreign key and the difference in id and name, but how to import the data?
need to write some kind of request?
This is the csv of the loaded data
Administrator,j.doe#amonic.com,123,John,Doe,Abu dhabi,1/13/1983,1
User,k.omar#amonic.com,4258,Karim,Omar,Abu dhabi,3/19/1980,1
User,h.saeed#amonic.com,2020,Hannan,Saeed,Cairo,12/20/1989,1
User,a.hobart#amonic.com,6996,Andrew,Hobart,Riyadh,1/30/1990,1
User,k.anderson#amonic.com,4570,Katrin,Anderson,Doha,11/10/1992,1
User,h.wyrick#amonic.com,1199,Hava,Wyrick,Abu dhabi,8/8/1988,1
User,marie.horn#amonic.com,55555,Marie,Horn,Bahrain,4/6/1981,1
User,m.osteen#amonic.com,9800,Milagros,Osteen,Abu dhabi,2/3/1991,0
and this is the mysql code
-- Dumping data for table `countries`
--
LOCK TABLES `countries` WRITE;
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
INSERT INTO `countries` VALUES (1,'Afghanistan'),(2,'Albania'),(3,'Algeria'),(4,'Andorra'),(5,'Angola'),(6,'Antigua & Deps'),(7,'Argentina'),(8,'Armenia'),(9,'Australia'),(10,'Austria'),(11,'Azerbaijan'),(12,'Bahamas'),(13,'Bahrain'),(14,'Bangladesh'),(15,'Barbados'),(16,'Belarus'),(17,'Belgium'),(18,'Belize'),(19,'Benin'),(20,'Bhutan'),(21,'Bolivia'),(22,'Bosnia Herzegovina'),(23,'Botswana'),(24,'Brazil'),(25,'Brunei'),(26,'Bulgaria'),(27,'Burkina'),(28,'Burundi'),(29,'Cambodia'),(30,'Cameroon'),(31,'Canada'),(32,'Cape Verde'),(33,'Central African Rep'),(34,'Chad'),(35,'Chile'),(36,'China'),(37,'Colombia'),(38,'Comoros'),(39,'Congo'),(40,'Congo {Democratic Rep}'),(41,'Costa Rica'),(42,'Croatia'),(43,'Cuba'),(44,'Cyprus'),(45,'Czech Republic'),(46,'Denmark'),(47,'Djibouti'),(48,'Dominica'),(49,'Dominican Republic'),(50,'East Timor'),(51,'Ecuador'),(52,'Egypt'),(53,'El Salvador'),(54,'Equatorial Guinea'),(55,'Eritrea'),(56,'Estonia'),(57,'Ethiopia'),(58,'Fiji'),(59,'Finland'),(60,'France'),(61,'Gabon'),(62,'Gambia'),(63,'Georgia'),(64,'Germany'),(65,'Ghana'),(66,'Greece'),(67,'Grenada'),(68,'Guatemala'),(69,'Guinea'),(70,'Guinea-Bissau'),(71,'Guyana'),(72,'Haiti'),(73,'Honduras'),(74,'Hungary'),(75,'Iceland'),(76,'India'),(77,'Indonesia'),(78,'Iran'),(79,'Iraq'),(80,'Ireland {Republic}'),(81,'Israel'),(82,'Italy'),(83,'Ivory Coast'),(84,'Jamaica'),(85,'Japan'),(86,'Jordan'),(87,'Kazakhstan'),(88,'Kenya'),(89,'Kiribati'),(90,'Korea North'),(91,'Korea South'),(92,'Kosovo'),(93,'Kuwait'),(94,'Kyrgyzstan'),(95,'Laos'),(96,'Latvia'),(97,'Lebanon'),(98,'Lesotho'),(99,'Liberia'),(100,'Libya'),(101,'Liechtenstein'),(102,'Lithuania'),(103,'Luxembourg'),(104,'Macedonia'),(105,'Madagascar'),(106,'Malawi'),(107,'Malaysia'),(108,'Maldives'),(109,'Mali'),(110,'Malta'),(111,'Marshall Islands'),(112,'Mauritania'),(113,'Mauritius'),(114,'Mexico'),(115,'Micronesia'),(116,'Moldova'),(117,'Monaco'),(118,'Mongolia'),(119,'Montenegro'),(120,'Morocco'),(121,'Mozambique'),(122,'Myanmar, {Burma}'),(123,'Namibia'),(124,'Nauru'),(125,'Nepal'),(126,'Netherlands'),(127,'New Zealand'),(128,'Nicaragua'),(129,'Niger'),(130,'Nigeria'),(131,'Norway'),(132,'Oman'),(133,'Pakistan'),(134,'Palau'),(135,'Panama'),(136,'Papua New Guinea'),(137,'Paraguay'),(138,'Peru'),(139,'Philippines'),(140,'Poland'),(141,'Portugal'),(142,'Qatar'),(143,'Romania'),(144,'Russian Federation'),(145,'Rwanda'),(146,'St Kitts & Nevis'),(147,'St Lucia'),(148,'Saint Vincent & the Grenadines'),(149,'Samoa'),(150,'San Marino'),(151,'Sao Tome & Principe'),(152,'Saudi Arabia'),(153,'Senegal'),(154,'Serbia'),(155,'Seychelles'),(156,'Sierra Leone'),(157,'Singapore'),(158,'Slovakia'),(159,'Slovenia'),(160,'Solomon Islands'),(161,'Somalia'),(162,'South Africa'),(163,'South Sudan'),(164,'Spain'),(165,'Sri Lanka'),(166,'Sudan'),(167,'Suriname'),(168,'Swaziland'),(169,'Sweden'),(170,'Switzerland'),(171,'Syria'),(172,'Taiwan'),(173,'Tajikistan'),(174,'Tanzania'),(175,'Thailand'),(176,'Togo'),(177,'Tonga'),(178,'Trinidad & Tobago'),(179,'Tunisia'),(180,'Turkey'),(181,'Turkmenistan'),(182,'Tuvalu'),(183,'Uganda'),(184,'Ukraine'),(185,'United Arab Emirates'),(186,'United Kingdom'),(187,'United States'),(188,'Uruguay'),(189,'Uzbekistan'),(190,'Vanuatu'),(191,'Vatican City'),(192,'Venezuela'),(193,'Vietnam'),(194,'Yemen'),(195,'Zambia'),(196,'Zimbabwe');
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `offices`
--
DROP TABLE IF EXISTS `offices`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `offices` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`CountryID` int(11) NOT NULL,
`Title` varchar(50) COLLATE utf8_bin NOT NULL,
`Phone` varchar(50) COLLATE utf8_bin NOT NULL,
`Contact` varchar(250) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ID`),
KEY `FK_Office_Country` (`CountryID`),
CONSTRAINT `FK_Office_Country` FOREIGN KEY (`CountryID`) REFERENCES `countries` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `offices`
--
LOCK TABLES `offices` WRITE;
/*!40000 ALTER TABLE `offices` DISABLE KEYS */;
INSERT INTO `offices` VALUES (1,185,'Abu dhabi','638-757-8582\r\n','MIchael Malki'),(3,52,'Cairo','252-224-8525','David Johns'),(4,13,'Bahrain','542-227-5825','Katie Ballmer'),(5,142,'Doha','758-278-9597','Ariel Levy'),(6,152,'Riyadh','285-285-1474','Andrew Hobart');
/*!40000 ALTER TABLE `offices` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `roles`
--
DROP TABLE IF EXISTS `roles`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `roles` (
`ID` int(11) NOT NULL,
`Title` varchar(50) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `roles`
--
LOCK TABLES `roles` WRITE;
/*!40000 ALTER TABLE `roles` DISABLE KEYS */;
INSERT INTO `roles` VALUES (1,'Administrator'),(2,'User');
/*!40000 ALTER TABLE `roles` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`ID` int(11) NOT NULL,
`RoleID` int(11) NOT NULL,
`Email` varchar(150) COLLATE utf8_bin NOT NULL,
`Password` varchar(50) COLLATE utf8_bin NOT NULL,
`FirstName` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`LastName` varchar(50) COLLATE utf8_bin NOT NULL,
`OfficeID` int(11) DEFAULT NULL,
`Birthdate` date DEFAULT NULL,
`Active` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `FK_Users_Offices` (`OfficeID`),
KEY `FK_Users_Roles` (`RoleID`),
CONSTRAINT `FK_Users_Offices` FOREIGN KEY (`OfficeID`) REFERENCES `offices` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_Users_Roles` FOREIGN KEY (`RoleID`) REFERENCES `roles` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `users`
--

Create Mysql tables

I downloaded the script that I want to install on my VPS, and as the creator who created this script said in the instructions, I import only the file that is called sql.sgl into the root folder where the database is created, but after that I can not run the script, and as I see in MySql no tables was created, so I wonder if there is a possibility to create everything from sql.sql file via commands in mysql, If someone can tell me just what commands in Linux I use to manually create all the tables and the rest from the file bellow:
anyway i just checked the error.log file and the error is on this script line 9 , please help , is this code ok ?
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_saha = "111.111.111.135";
$database_saha = "search";
$username_saha = "root";
$password_saha = "me111";
$saha = mysqli_connect($hostname_saha, $username_saha, $password_saha, $database_saha) or trigger_error(mysqli_error($saha),E_USER_ERROR);
mysqli_set_charset( $saha, 'utf8');
?>
-- version 4.6.0
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Dec 04, 2016 at 12:02 PM
-- Server version: 5.5.52-cll-lve
-- 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: `hello`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id` int(11) NOT NULL,
`un` varchar(30) NOT NULL,
`pw` varchar(30) NOT NULL,
`demo` enum('Y','N') NOT NULL DEFAULT 'Y',
`max_pages` int(11) DEFAULT '20',
`max_content` int(11) DEFAULT '500'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `un`, `pw`, `demo`, `max_pages`, `max_content`) VALUES
(1, 'administrator', 'admin', 'N', 20, 500);
-- --------------------------------------------------------
--
-- Table structure for table `crawl`
--
CREATE TABLE `crawl` (
`id` int(11) NOT NULL,
`base_url` varchar(1000) NOT NULL,
`actual_url` varchar(2000) NOT NULL,
`title` varchar(2500) NOT NULL,
`description` varbinary(200) DEFAULT NULL,
`keywords` varbinary(200) DEFAULT NULL,
`content` varchar(500) DEFAULT NULL,
`current_url` varchar(2000) NOT NULL,
`last_update` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` enum('Y','N') DEFAULT 'N',
`block_update` enum('Y','N') DEFAULT 'N',
`visits` int(11) DEFAULT '0',
`manual` enum('Y','N') DEFAULT 'N'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `settings`
--
CREATE TABLE `settings` (
`id` int(11) NOT NULL,
`base_url` varchar(1000) NOT NULL,
`actual_url` varchar(2000) NOT NULL,
`demo` enum('Y','N') DEFAULT 'N',
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `un` (`un`),
ADD UNIQUE KEY `un_2` (`un`);
--
-- Indexes for table `crawl`
--
ALTER TABLE `crawl`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `settings`
--
ALTER TABLE `settings`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `crawl`
--
ALTER TABLE `crawl`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=747;
--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
/*!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 */;```

SQL Syntax Error - Can't Import

I have been trying to import this query but it doesn't seem to work?
-- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server versie: 10.1.21-MariaDB - mariadb.org binary distribution
-- Server OS: Win64
-- HeidiSQL Versie: 9.3.0.4984
-- --------------------------------------------------------
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8mb4 */;
/*!40014 SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- Databasestructuur van gta5_gamemode_essential wordt geschreven
CREATE DATABASE IF NOT EXISTS `gta5_gamemode_essential` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `gta5_gamemode_essential`;
-- Structuur van tabel gta5_gamemode_essential.bans wordt geschreven
CREATE TABLE IF NOT EXISTS `bans` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`banned` varchar(50) NOT NULL DEFAULT '0',
`banner` varchar(50) NOT NULL,
`reason` varchar(150) NOT NULL DEFAULT '0',
`expires` datetime NOT NULL,
`timestamp` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Data exporteren was gedeselecteerd
-- Structuur van tabel gta5_gamemode_essential.users wordt geschreven
CREATE TABLE IF NOT EXISTS `users` (
`identifier` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
`group` varchar(50) NOT NULL DEFAULT '0',
`permission_level` int(11) NOT NULL DEFAULT '0',
`money` double NOT NULL DEFAULT '0',
`weapons` varchar(5000) CHARACTER SET utf8 NOT NULL,
`personalvehicle` varchar(10000) CHARACTER SET utf8 NOT NULL,
`withdraw_cost` int(10) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Data exporteren was gedeselecteerd
/*!40101 SET SQL_MODE=IFNULL(#OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(#OLD_FOREIGN_KEY_CHECKS IS NULL, 1, #OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=#OLD_CHARACTER_SET_CLIENT */;
`withdraw_cost` int(10) NOT NULL, -- Remove this comma
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
users needs a PRIMARY KEY. Or maybe you are missing the PRIMARY KEY clause??