Jump to content

loading a txt file into mysql to create a database


CherryLips
Go to solution Solved by Ch0cu3r,

Recommended Posts

Hello,

 

I am trying to load a txt file into mysql -uroot to create a database with all the tables and everything is prewritten. Here is what I thought I was supposed to write (but it's not working):

 

mysql -uroot < skel_mysql.txt

 

the skel_mysql.txt file is located in xampp/mysql/bin and this is a copy of the text in the file.

 

CREATE DATABASE skel;
USE skel;

CREATE TABLE customers (
ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
LAST CHAR(20) NOT NULL,
FIRST CHAR(20) NOT NULL,
PHONE CHAR(20) NOT NULL,
SESSID CHAR(32) NOT NULL );

CREATE TABLE products (
SKU INT NOT NULL PRIMARY KEY,
NAME CHAR(20) NOT NULL,
DESCR VARCHAR(40) NOT NULL,
PRICE DECIMAL(9,2) NOT NULL,
IMAGE VARCHAR(20) NOT NULL );

INSERT INTO products VALUES(1121,'Small Lab Coat','White Lab Coat Adult Small',15.75,'labcoat.png'),
(1122,'Medium Lab Coat','White Lab Coat Adult Medium',15.75,'labcoat.png'),
(1123,'Large Lab Coat','White Lab Coat Adult Large',16.75,'labcoat.png'),
(1124,'Beaker Kit','Set of 5 different beakers',22.05,'beakers.png'),
(1125,'Petri Dishes','Set of three',9.99,'petri.png'),
(1126,'Safety Glasses','Women's Safety Glasses',15.75,'wmglass.png'),
(1127,'Mens Safety Glasses','Men's Safety Glasses',15.75,'mglass.png'),
(1128,'Kids Safety Glasses','Kid's Safety Glasses',15.75, 'kglass.png'), ;


CREATE TABLE cart (
ID CHAR(32) NOT NULL,
DATE DATETIME NOT NULL,
QTY INT NOT NULL,
SKU INT NOT NULL );

 

Side note: I thought there was an error in my database so I dropped it and rewrote the code in a txt file and now I dont want to rewrite everything in the cmd prompt. This is for a simple shopping cart assignment Im doing for a PHP class.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.