SQL Syntax Error - Can't Import - mysql

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??

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?

Slow MySQL Query "copying to tmp table", help re-writing it

This mysql query is extremely slow, when I look at the query it is "copying to tmp table". These tables are very large especially search_attribute (79 million rows) and search_attribute_values (350,000 rows)
SELECT attributenames.name, search_attribute_values.value
FROM attributenames, categorysearchattributes, search_attribute, search_attribute_values
WHERE
categorysearchattributes.attributeid = attributenames.attributeid AND categorysearchattributes.categoryid = 4800 AND
categorysearchattributes.attributeid = search_attribute.attributeid AND
search_attribute.valueid = search_attribute_values.valueid AND
attributenames.localeid = 1
GROUP BY search_attribute.valueid
Here is a picture of the EXPLAIN of the query
Here is my database schema
-- MySQL dump 10.13 Distrib 5.5.46, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database:
-- ------------------------------------------------------
-- Server version 5.5.46-0ubuntu0.14.04.2
/*!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 utf8 */;
/*!40103 SET #OLD_TIME_ZONE=##TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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' */;
/*!40111 SET #OLD_SQL_NOTES=##SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `attributenames`
--
DROP TABLE IF EXISTS `attributenames`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `attributenames` (
`attributeid` bigint(20) NOT NULL DEFAULT '0',
`name` varchar(110) NOT NULL DEFAULT '',
`localeid` int(11) NOT NULL DEFAULT '0',
KEY `attributenames_attributeID` (`attributeid`),
KEY `attributenames_localeID` (`localeid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `categorysearchattributes`
--
DROP TABLE IF EXISTS `categorysearchattributes`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `categorysearchattributes` (
`categoryid` int(11) NOT NULL DEFAULT '0',
`attributeid` bigint(20) NOT NULL DEFAULT '0',
`isactive` tinyint(1) NOT NULL DEFAULT '1',
KEY `caterysearchattributes_aID` (`attributeid`),
KEY `caterysearchattributes_cID` (`categoryid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `product`
--
DROP TABLE IF EXISTS `product`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `product` (
`productid` int(11) NOT NULL DEFAULT '0',
`manufacturerid` int(11) NOT NULL DEFAULT '0',
`isactive` tinyint(1) NOT NULL DEFAULT '1',
`mfgpartno` varchar(70) NOT NULL DEFAULT '',
`categoryid` int(11) NOT NULL DEFAULT '0',
`isaccessory` tinyint(1) NOT NULL DEFAULT '0',
`equivalency` double NOT NULL DEFAULT '0',
`creationdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modifieddate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lastupdated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`productid`),
KEY `product_manufacturerID` (`manufacturerid`),
KEY `product_categoryID` (`categoryid`),
KEY `product_mfgPartNo` (`mfgpartno`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `search_attribute`
--
DROP TABLE IF EXISTS `search_attribute`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `search_attribute` (
`productid` int(11) NOT NULL DEFAULT '0',
`attributeid` bigint(20) NOT NULL DEFAULT '0',
`valueid` int(11) NOT NULL DEFAULT '0',
`localeid` int(11) NOT NULL DEFAULT '0',
`setnumber` tinyint(2) NOT NULL DEFAULT '0',
`isactive` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`productid`,`localeid`,`attributeid`,`setnumber`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `search_attribute_values`
--
DROP TABLE IF EXISTS `search_attribute_values`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `search_attribute_values` (
`valueid` int(11) NOT NULL DEFAULT '0',
`value` varchar(255) NOT NULL DEFAULT '',
`absolutevalue` double NOT NULL DEFAULT '0',
`unitid` int(11) NOT NULL DEFAULT '0',
`isabsolute` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`valueid`),
KEY `search_attrval_value` (`value`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
Added attributeid_valueid index
By looking at the EXPLAIN query in the picture, the table search_attribute is doing a full table scan i.e. not using indexes at all.
Adding index to valueid column of search_attribute table should make it faster. Give it a try and share your results after adding index.
ALTER TABLE `search_attribute` ADD KEY `idx_valueid` (`valueid`);
Please try the combinations of suggestions below.

Cannot add foreign key constraint

First, here's my main reference table mysql dump
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Nov 17, 2015 at 03:15 AM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
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 utf8 */;
--
-- Database: `j_inventory`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(200) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(500) COLLATE utf8_unicode_ci NOT NULL, `real_password` varchar(250) COLLATE utf8_unicode_ci NOT NULL, `role` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `full_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL, `remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `status` varchar(100) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=44 ;
/*!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 */;
and the second table where the hopefully the foreign key resides
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Nov 17, 2015 at 03:14 AM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
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 utf8 */;
--
-- Database: `j_inventory`
--
-- --------------------------------------------------------
--
-- Table structure for table `user_details`
--
CREATE TABLE IF NOT EXISTS `user_details` ( `id` int(11) NOT NULL AUTO_INCREMENT, `phone` varchar(200) NOT NULL, `age` int(100) NOT NULL, `gender` varchar(50) NOT NULL, `address` varchar(250) NOT NULL, `course` varchar(250) NOT NULL, `college` varchar(200) NOT NULL, `year` int(11) NOT NULL, `user_id` int(100) NOT NULL, `updated_at` timestamp NOT NULL, `created_at` timestamp NOT NULL, PRIMARY KEY (`id`), KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
/*!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 */;
the foreign key (not set up due to mysql error "Cannot add foreign key constraint ") in the users_details is the 'user_id' and the reference table is the 'users' table where the reference key for the foreign key is the 'user_id' on the users table and I tried this
ALTER TABLE user_details ADD FOREIGN KEY fk1(user_id) REFERENCES
users(user_id) ON DELETE CASCADE ON UPDATE NO ACTION;
but sadly and unfortunately it throws me an error
Error SQL query:
ALTER TABLE user_details ADD CONSTRAINT fk1 FOREIGN KEY
(user_id) REFERENCES j_inventory.users(user_id) ON DELETE
CASCADE ON UPDATE NO ACTION; MySQL said: Documentation
1215 - Cannot add foreign key constraint Documentation
any help, clues, ideas, suggestions, recommendations please?
Your user id is unsigned on the users table. Remove 'unsigned' from this field in your users table create statement and see if it works. I think what you're seeing is an error caused by a mismatch between the user_id field types on your users and user_details tables

Cannot create a table in mysql error(150)

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.

Mysql Database not creating table [messy code]

I tried to add this:
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 09, 2013 at 04:43 PM
-- Server version: 5.5.16
-- PHP Version: 5.3.8
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 utf8 */;
--
-- Database: `rezzion`
--
-- --------------------------------------------------------
--
-- Table structure for table `punishments`
--
CREATE TABLE IF NOT EXISTS `punishments` (
`username` varchar(20) NOT NULL AUTO_INCREMENT,
`punisher` varchar(20) NOT NULL,
`server` varchar(15) NOT NULL,
`type` int(255) NOT NULL,
`date` varchar(1024) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!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 */;
to my database "rezzion" & for some reason i'm getting this error:
Anyone know why it's doing this? I have my database set to utf8-bin & it's name is rezzion... I'm confused why the code above isn't working?
Your error starts, at least, here:
`username` varchar(20) NOT NULL AUTO_INCREMENT,
This is not allowed in MySQL. And, besides, you're declaring primary key with another column:
PRIMARY KEY (`id`)
Auto Increment can only be used on a INT change it to a integer and your problem is solved
AUTO_INCREMENT my only be used with number types. You are applying it to a VARCHAR column. Also, you specify an "id" column as your primary key which does not exist.
You probably want it to look like this:
CREATE TABLE IF NOT EXISTS `punishments` (
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` varchar(20) NOT NULL,
`punisher` varchar(20) NOT NULL,
`server` varchar(15) NOT NULL,
`type` int(255) NOT NULL,
`date` varchar(1024) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;