Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Unanswered: Getting error when trying to execute sql script file

    I need some help. I've never used MySQL before and am now learning it.
    I'm trying to create a table within an existing database:
    here is the error:

    mysql> use Testing;
    Database changed
    mysql> select database();
    +-----------------+
    | database() |
    +-----------------+
    |Testing|
    +-----------------+
    1 row in set (0.00 sec)

    mysql> < create_info.sql
    -> \g
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '< create_info.sql' at line 1
    mysql> mysql Testing < create_info.sql;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql Testing < create_info.sql' at line 1
    mysql> mysql bbmc_employment < c:\create_info.sql;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'reate_info.sql' at line 1

    Here is the SQL script file:

    Create Table Info
    {
    EmailAddress VARCHAR(45) NOT NULL,
    PRIMARY KEY (EmailAddress),
    Password VARCHAR(15) NOT NULL,
    FName VARCHAR(15) NOT NULL,
    LName VARCHAR(20) NOT NULL,
    Address1 VARCHAR(35) NOT NULL,
    Address2 VARCHAR(20) NULL,
    City VARCHAR(20) NOT NULL,
    State VARCHAR(2) NOT NULL,
    ZipCode VARCHAR(10) NOT NULL,
    Phone1 VARCHAR(12) NOT NULL,
    Phone2 VARCHAR(12) NULL
    };


    Any ideas...????

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Swap the { and } for ( and ) ?
    George
    Home | Blog

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    looks to me like you are trying to pass a shell command to the mysql database

    how come you aren't using a tool like the mysql query browser, phpmyadmin, heidisql, sqlyog, navicat... ?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Sep 2009
    Posts
    64
    You need to do it from command line. Here's the command line:

    Code:
    mysql -u username -p password  -h hostname Testing < create_info.sql

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •