Create Mysql tables - mysql

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

Related

mysql update parent updates all column values in child

I have the following tables:
-users(not important here)
-students
-courses
-enrollments
the students and courses table have a "active column"
the enrollments table have a "course_active" and "student_active" column.
I am trying to set my DB in such a way that when I change active for student or course this will cascade to enrollments.
Unfortunately I am seeing that when I update an active value on "students/courses"
the whole column of "student active" or "course active" changes.
I would truly appreciate your input and assistance on this matter.
link to a fiddle for convenience:
http://sqlfiddle.com/#!9/8e2ce
here is my SQL:
-- phpMyAdmin SQL Dump
-- version 4.8.0.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Apr 20, 2018 at 08:32 AM
-- Server version: 10.1.28-MariaDB
-- PHP Version: 7.1.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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: `schoolcrm2`
--
-- --------------------------------------------------------
--
-- Table structure for table `courses`
--
CREATE TABLE `courses` (
`id` int(5) NOT NULL,
`name` varchar(50) NOT NULL,
`description` text NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`active` tinyint(1) NOT NULL DEFAULT '1',
`added_by` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `enrollments`
--
CREATE TABLE `enrollments` (
`id` int(5) NOT NULL,
`student_id` int(11) NOT NULL,
`course_id` int(11) NOT NULL,
`user_id` int(11) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`student_active` int(1) NOT NULL DEFAULT '1',
`course_active` int(1) NOT NULL DEFAULT '1',
`added_by` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `students`
--
CREATE TABLE `students` (
`id` int(5) NOT NULL,
`email` varchar(40) NOT NULL,
`name` varchar(30) NOT NULL,
`phone` varchar(30) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`active` tinyint(1) NOT NULL DEFAULT '1',
`added_by` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(5) NOT NULL,
`email` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`phone` varchar(30) NOT NULL,
`password` varchar(255) NOT NULL,
`role` enum('1','2','3') DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`active` tinyint(1) NOT NULL DEFAULT '1',
`added_by` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `courses`
--
ALTER TABLE `courses`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `enrollments`
--
ALTER TABLE `enrollments`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `students`
--
ALTER TABLE `students`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `courses`
--
ALTER TABLE `courses`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `enrollments`
--
ALTER TABLE `enrollments`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `students`
--
ALTER TABLE `students`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT;
ALTER TABLE `enrollments`
ADD CONSTRAINT `enrollments_to_courses` FOREIGN KEY (`course_active`) REFERENCES `courses` (`is_active`) ON UPDATE CASCADE,
ADD CONSTRAINT `enrollments_to_students` FOREIGN KEY (`student_active`) REFERENCES `students` (`is_active`) ON UPDATE CASCADE;
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 */;

Wordpress thousand of categories crashing site

I have a big website, at the moment i have about 10k unique visitors daily, I have 2000 categories, 12k Tags, 36k custom taxonomies.
It's not a design flaw, as its a website to watch online movies, I used, categories for Seasons and stuff like that, the custom taxonomies are Actors, regizors etc.
The problem is that my hosting keeps crashing with 100% processor, the resources cannot be an issue, as i have my own server with 4xXeon, 64 GB ram.
I have isolated the problem, and it's due to very slow queries for example, what are my options? :
# Time: 160830 17:01:20
# User#Host: razvypp[razvypp] # localhost []
# Query_time: 9.159090 Lock_time: 0.001680 Rows_sent: 30 Rows_examined: 420117
SET timestamp=1472565680;
SELECT wphn_posts.ID
FROM wphn_posts
INNER JOIN wphn_term_relationships
ON (wphn_posts.ID = wphn_term_relationships.object_id)
WHERE 1=1
AND ( wphn_term_relationships.term_taxonomy_id IN (3630,
4955,4956,4957,4958,4959,4960,4961,4962,4963,4964,4965,
4966,4967,4968,4969,4970,4971,4972,4973,4974,4975,4976,
4977,4978,4979,4980,4981,4982,4983,4984,4985,4986,4987,
4988,4989,4990,4991,4992,4993,4994,4995,4996,4997,4998,
4999,5000,5001,5002,5003,5004,5005,5006,5007,5008,5009,
5010,5011,5012, ... (hundreds of numbers) ...,49740,49779)
Here is a dump of the tables
-- phpMyAdmin SQL Dump
-- version 4.4.15
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: 30 Aug 2016 la 15:17
-- Versiune server: 5.5.51-log
-- PHP Version: 5.5.37
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: `trolio`
--
-- --------------------------------------------------------
--
-- Structura de tabel pentru tabelul `wphn_posts`
--
CREATE TABLE IF NOT EXISTS `wphn_posts` (
`ID` bigint(20) unsigned NOT NULL,
`movie_type` int(2) NOT NULL,
`post_author` bigint(20) unsigned NOT NULL DEFAULT '0',
`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content` longtext NOT NULL,
`post_title` text NOT NULL,
`post_excerpt` text NOT NULL,
`post_status` varchar(20) NOT NULL DEFAULT 'publish',
`comment_status` varchar(20) NOT NULL DEFAULT 'open',
`ping_status` varchar(20) NOT NULL DEFAULT 'open',
`post_password` varchar(20) NOT NULL DEFAULT '',
`post_name` varchar(200) NOT NULL DEFAULT '',
`to_ping` text NOT NULL,
`pinged` text NOT NULL,
`post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content_filtered` longtext NOT NULL,
`post_parent` int(20) unsigned NOT NULL DEFAULT '0',
`guid` varchar(255) NOT NULL DEFAULT '',
`menu_order` int(11) NOT NULL DEFAULT '0',
`post_type` varchar(20) NOT NULL DEFAULT 'post',
`post_mime_type` varchar(100) NOT NULL DEFAULT '',
`comment_count` bigint(20) NOT NULL DEFAULT '0',
`views` int(99) NOT NULL,
`views_this_week` int(5) NOT NULL,
`imdb` double NOT NULL,
`imdb_votes` float NOT NULL,
`imdb_id` varchar(20) NOT NULL,
`fb_shares_root` int(5) NOT NULL,
`movie_name` varchar(140) NOT NULL,
`season` int(2) NOT NULL,
`episode` int(5) NOT NULL,
`serial_id` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structura de tabel pentru tabelul `wphn_term_relationships`
--
CREATE TABLE IF NOT EXISTS `wphn_term_relationships` (
`object_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`term_taxonomy_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`term_order` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structura de tabel pentru tabelul `wphn_term_taxonomy`
--
CREATE TABLE IF NOT EXISTS `wphn_term_taxonomy` (
`term_taxonomy_id` bigint(20) unsigned NOT NULL,
`term_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`taxonomy` varchar(32) NOT NULL DEFAULT '',
`description` longtext NOT NULL,
`parent` bigint(20) unsigned NOT NULL DEFAULT '0',
`count` bigint(20) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `wphn_posts`
--
ALTER TABLE `wphn_posts`
ADD PRIMARY KEY (`ID`),
ADD KEY `post_name` (`post_name`(191)),
ADD KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
ADD KEY `post_parent` (`post_parent`),
ADD KEY `post_author` (`post_author`),
ADD KEY `serial_id` (`serial_id`),
ADD KEY `episode` (`episode`),
ADD KEY `season` (`season`),
ADD KEY `movie_name` (`movie_name`);
--
-- Indexes for table `wphn_term_relationships`
--
ALTER TABLE `wphn_term_relationships`
ADD PRIMARY KEY (`object_id`,`term_taxonomy_id`),
ADD KEY `term_taxonomy_id` (`term_taxonomy_id`),
ADD KEY `term_order` (`term_order`);
--
-- Indexes for table `wphn_term_taxonomy`
--
ALTER TABLE `wphn_term_taxonomy`
ADD PRIMARY KEY (`term_taxonomy_id`),
ADD UNIQUE KEY `term_id_taxonomy` (`term_id`,`taxonomy`),
ADD KEY `taxonomy` (`taxonomy`),
ADD KEY `parent` (`parent`),
ADD KEY `count` (`count`),
ADD KEY `term_id` (`term_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `wphn_posts`
--
ALTER TABLE `wphn_posts`
MODIFY `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `wphn_term_taxonomy`
--
ALTER TABLE `wphn_term_taxonomy`
MODIFY `term_taxonomy_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
/*!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 */;
"Rows examined" = 420K -- That smacks of a missing index.
Probably missing:
INDEX(term_taxonomy_id, object_id)
Please provide SHOW CREATE TABLE for the two tables.
What is the value of innodb_buffer_pool_size?

#1064 SQL Syntax error

I understand this is a common and annoying problem so before I ask for an explanation I just want to say sorry.
As the title says I've been getting a 1064 syntax error from my MySQL db I imported in to php myadmin running wamp and building through netbeans.
I've checked out how other posts on the matter and have done reading about proper syntax but cannot see what my problem is.
An explanation would be greatly appreciated as I really want to learn this and improve my skills.
(if you have any questions about my code please ask)
Here's my full code:
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: `mydb`
--
CREATE DATABASE IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `mydb`;
-- --------------------------------------------------------
--
-- Table structure for table `follow`
--
DROP TABLE IF EXISTS `follow`;
CREATE TABLE IF NOT EXISTS `follow` (
`follow_id` int(11) NOT NULL,
`follow_current_user` varchar(255) NOT NULL,
`follow_profile_user` varchar(255) NOT NULL,
`follow_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;
--
-- Dumping data for table `follow`
--
INSERT INTO `follow` (`follow_id`, `follow_current_user`, `follow_profile_user`, `follow_timestamp`) VALUES
(13, 'dude', 'the', '2015-10-10 03:09:58'),
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(11) NOT NULL,
`user_email` varchar(255) NOT NULL,
`user_password` varchar(255) NOT NULL,
`user_firstname` text NOT NULL,
`user_lastname` text NOT NULL,
`user_avatar` varchar(255) NOT NULL,
`user_shortbio` text,
`user_username` varchar(255) NOT NULL,
`user_longbio` text,
`user_facebook` varchar(255) DEFAULT NULL,
`user_twitter` varchar(255) DEFAULT NULL,
`user_linkedin` varchar(255) DEFAULT NULL,
`user_stumbleupon` varchar(255) DEFAULT NULL,
`user_pinterest` varchar(255) DEFAULT NULL,
`user_googleplus` varchar(255) DEFAULT NULL,
`user_website` varchar(255) DEFAULT NULL,
`user_dob` date DEFAULT NULL,
`user_profession` text,
`user_gender` varchar(255) DEFAULT NULL,
`user_maritialstatus` varchar(255) DEFAULT NULL,
`user_address` text,
`user_backgroundpicture` varchar(255) NOT NULL,
`user_joindate` date NOT NULL,
`user_country` varchar(255) DEFAULT NULL,
`user_skype` varchar(255) DEFAULT NULL,
`user_github` varchar(255) DEFAULT NULL,
`user_youtube` varchar(255) DEFAULT NULL,
`user_vimeo` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`user_id`, `user_email`, `user_password`, `user_firstname`, `user_lastname`, `user_avatar`, `user_shortbio`, `user_username`, `user_longbio`, `user_facebook`, `user_twitter`, `user_linkedin`, `user_stumbleupon`, `user_pinterest`, `user_googleplus`, `user_website`, `user_dob`, `user_profession`, `user_gender`, `user_maritialstatus`, `user_address`, `user_backgroundpicture`, `user_joindate`, `user_country`, `user_skype`, `user_github`, `user_youtube`, `user_vimeo`) VALUES
(1, 'me#gmail.com', '123password123', 'Forname', 'Surname', '1470024_601216136604826_1065650331_n-884862517.jpg', 'Lorem ipsum.', 'username', 'Lorem ipsum', NULL, NULL, NULL, NULL, NULL, NULL, 'mysite.com', '1987-11-11', 'Student', 'Male', NULL, 'kablah', 'untitled-90969185.jpg', '2015- 11-11', 'Country', NULL, NULL, NULL, NULL),
--
-- --------------------------------------------------------
--
-- Table structure for table `view`
--
DROP TABLE IF EXISTS `view`;
CREATE TABLE IF NOT EXISTS `view` (
`view_id` int(11) NOT NULL,
`view_profile_user` varchar(255) NOT NULL,
`view_current_user` varchar(255) NOT NULL,
`view_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=123 ;
--
-- Dumping data for table `view`
--
INSERT INTO `view` (`view_id`, `view_profile_user`, `view_current_user`, `view_timestamp`) VALUES
(65, 'blub', 'rugsworth', '2015-10-18 19:30:56'),
--
-- Indexes for dumped tables
--
--
-- Indexes for table `follow`
--
ALTER TABLE `follow`
ADD PRIMARY KEY (`follow_id`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`), ADD UNIQUE KEY `user_email` (`user_email`), ADD UNIQUE KEY `user_username` (`user_username`);
--
-- Indexes for table `view`
--
ALTER TABLE `view`
ADD PRIMARY KEY (`view_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `follow`
--
ALTER TABLE `follow`
MODIFY `follow_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `view`
--
ALTER TABLE `view`
MODIFY `view_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=123;
/*!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 just the part of my code I think is causing the problem:
-- Dumping data for table `user`
--
INSERT INTO `user` (`user_id`, `user_email`, `user_password`, `user_firstname`, `user_lastname`, `user_avatar`, `user_shortbio`, `user_username`, `user_longbio`, `user_facebook`, `user_twitter`, `user_linkedin`, `user_stumbleupon`, `user_pinterest`, `user_googleplus`, `user_website`, `user_dob`, `user_profession`, `user_gender`, `user_maritialstatus`, `user_address`, `user_backgroundpicture`, `user_joindate`, `user_country`, `user_skype`, `user_github`, `user_youtube`, `user_vimeo`) VALUES
(1, 'me#gmail.com', '123password123', 'Forname', 'Surname', '1470024_601216136604826_1065650331_n-884862517.jpg', 'Lorem ipsum.', 'username', 'Lorem ipsum', NULL, NULL, NULL, NULL, NULL, NULL, 'mysite.com', '1987-11-11', 'Student', 'Male', NULL, 'kablah', 'untitled-90969185.jpg', '2015- 11-11', 'Country', NULL, NULL, NULL, NULL),
--
-- --------------------------------------------------------
--
-- Table structure for table `view`
--
DROP TABLE IF EXISTS `view`;
CREATE TABLE IF NOT EXISTS `view` (
`view_id` int(11) NOT NULL,
`view_profile_user` varchar(255) NOT NULL,
`view_current_user` varchar(255) NOT NULL,
`view_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=123 ;
--
-- Dumping data for table `view`
--
INSERT INTO `view` (`view_id`, `view_profile_user`, `view_current_user`, `view_timestamp`) VALUES
(65, 'blub', 'rugsworth', '2015-10-18 19:30:56'),
You have a comma at the end of your INSERT INTO 'view' statement instead of a semicolon.
Should be:
INSERT INTO `view` (`view_id`, `view_profile_user`, `view_current_user`, `view_timestamp`)
VALUES (65, 'blub', 'rugsworth', '2015-10-18 19:30:56');
Does that fix it up?

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 ;