-2

I worked on this project on another computer and everything was working fine. Once I pulled it to this computer mac, I started to get a bunch of Error code 30000 when I'm trying to run the statements. I am using NetBeans and I'm trying to run the statements on NetBeans also.

CREATE DATABASE Coffee_Shop_Test;
USE Coffee_Shop_Test;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`enabled` tinyint(1) NOT NULL,
PRIMARY KEY (`user_id`),
KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `posts` (
`post_id` int(11) NOT NULL AUTO_INCREMENT,
`author` varchar(50) NOT NULL,
`content` text NOT NULL,
`post_date` datetime NOT NULL,
 PRIMARY KEY (`post_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `comments` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`author` varchar(50) NOT NULL,
`content` tinytext NOT NULL,
`comment_date` datetime NOT NULL,
PRIMARY KEY (`comment_id`),
FOREIGN KEY (`post_id`) REFERENCES posts(`post_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `tags` (
`tag_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(25),
PRIMARY KEY (`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `products` (
`product_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`price` decimal(5, 2),
PRIMARY KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `orders` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`total` decimal(7, 2) NOT NULL,
PRIMARY KEY (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


...


CREATE TABLE IF NOT EXISTS `order_details` (
`order_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
 KEY `order_id` (`order_id`),
 KEY `product_id` (`product_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `post_approval` (
`post_id` int(11) NOT NULL,
`approval` boolean NOT NULL,
KEY `post_id` (`post_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `posts_tags` (
`post_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL,
KEY `post_id` (`post_id`),
KEY `tag_id` (`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



CREATE TABLE IF NOT EXISTS `authorities` (
`username` varchar(20) NOT NULL,
`authority` varchar(20) NOT NULL,
KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



ALTER TABLE `post_approval`
ADD CONSTRAINT `post_approval_post_idfk` FOREIGN KEY (`post_id`)          
REFERENCES `posts` (`post_id`);



ALTER TABLE `authorities`
ADD CONSTRAINT `authorities_usernamefk` FOREIGN KEY (`username`)   
REFERENCES `users` (`username`);



ALTER TABLE `comments`
ADD CONSTRAINT `commentspk_postsfk` FOREIGN KEY (`post_id`) REFERENCES
`posts` (`post_id`) ON DELETE NO ACTION;



ALTER TABLE `order_details`
ADD CONSTRAINT `order_details_orderfk` FOREIGN KEY (`order_id`)      
REFERENCES `orders` (`order_id`) ON DELETE NO ACTION,
ADD CONSTRAINT `order_details_productfk` FOREIGN KEY (`product_id`) 
REFERENCES `products` (`product_id`) ON DELETE NO ACTION;



ALTER TABLE `posts_tags`
ADD CONSTRAINT `posts_tags_postfk` FOREIGN KEY (`post_id`) REFERENCES
`posts` (`post_id`) ON DELETE NO ACTION,
ADD CONSTRAINT `posts_tags_tagfk` FOREIGN KEY (`tag_id`) REFERENCES
`tags` (`tag_id`) ON DELETE NO ACTION;

Error code 30000, SQL state 42X01: Syntax error: Encountered "DATABASE" at line 1, column 8. Line 1, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "USE" at line 1, column 1. Line 2, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "SQL_MODE" at line 1, column 5. Line 3, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "time_zone" at line 1, column 5. Line 4, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 8, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 19, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 29, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 41, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 49, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 58, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 72, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 82, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 90, column 1

Error code 30000, SQL state 42X01: Syntax error: Encountered "NOT" at line 1, column 17. Line 99, column 1

Error code 30000, SQL state 42X02: Lexical error at line 1, column 13. Encountered: "`" (96), after : "". Line 107, column 1

Error code 30000, SQL state 42X02: Lexical error at line 1, column 13. Encountered: "`" (96), after : "". Line 113, column 1

Error code 30000, SQL state 42X02: Lexical error at line 1, column 13. Encountered: "`" (96), after : "". Line 119, column 1

Error code 30000, SQL state 42X02: Lexical error at line 1, column 13. Encountered: "`" (96), after : "". Line 125, column 1

Error code 30000, SQL state 42X02: Lexical error at line 1, column 13. Encountered: "`" (96), after : "". Line 133, column 1

Execution finished after 0 s, 19 error(s) occurred.

I even just trying to create a simple table but aint working either. The default schema is also sent on that DBs.

picture

Redbeard011010
  • 943
  • 6
  • 20
0xtimur
  • 883
  • 2
  • 9
  • 13

1 Answers1

0

I had not installed and set-up mySQL correctly because I did not know you had to.

I have the linked I used to set it up.

https://netbeans.org/kb/docs/ide/mysql.html

0xtimur
  • 883
  • 2
  • 9
  • 13
  • I am glad you got to the root of the problem. When issues like these crop up, start from the most basic item - i.e. is MySQL responding? In your case, doing so helped detect that MySQL server wasn't installed. You can mark your own answer as accepted to give closure to your question. – zedfoxus Dec 26 '15 at 22:46