If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > mysql command in batch mode on Windows98

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-04, 09:19
DonalR DonalR is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
mysql command in batch mode on Windows98

Hopefully someone can help me with this....

I recently installed MySQL (standard installation) on Windows 98, and created a test database to practice on. I have no difficulty connecting to the database or creating tables manually.

However, I wanted to use the mysql command in batch mode to run a .sql script to create tables in the database. The MySQL manual says to type 'mysql <filename.sql', or 'source filename.sql'. I have tried this but neither option has worked. I always get the message

"
ERROR 1064: 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 <schema.sql' at line 1
"

How can there be a syntax error with such a basic command?
I am using mysqlc to enter the command. I've seen it suggested elsewhere to close the database and type the file path from the standard c: prompt, but this did not work. Also, I found out that there should be no comment lines with the # character in the .sql file. I took these out but it did not make any difference. The .sql file is stored in the directory 'c:mysql\data\databasename'.

Is there something I should do in the MySQL configuration to make the mysqlc window recognise the mysql batch command? Is there a bug in mysqlc?

Someone help before I go back to MSAccess...
Reply With Quote
  #2 (permalink)  
Old 04-09-04, 12:14
sqlhack sqlhack is offline
Registered User
 
Join Date: Dec 2002
Location: California
Posts: 32
Please no, anything but Microsoft!

did you put an end of line character on the end of the mysql command (that would be a ';'). If you could copy and paste you batch file into the forums that would be helpfull.
Reply With Quote
  #3 (permalink)  
Old 04-09-04, 13:49
DonalR DonalR is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
I did put the ; at the end of the statement. Should have put that in the first post.

The text of the .sql file (which came with a banner ad tracking utility) is as follows:

CREATE TABLE adclicks (
bannerID mediumint(9) DEFAULT '0' NOT NULL,
t_stamp timestamp(14),
host varchar(255) NOT NULL,
KEY clientID (bannerID)
);
CREATE TABLE adviews (
bannerID mediumint(9) DEFAULT '0' NOT NULL,
t_stamp timestamp(14),
host varchar(255) NOT NULL,
KEY clientID (bannerID)
);
CREATE TABLE banners (
bannerID mediumint(9) NOT NULL auto_increment,
clientID mediumint(9) DEFAULT '0' NOT NULL,
banner blob NOT NULL,
width smallint(6) DEFAULT '0' NOT NULL,
height smallint(6) DEFAULT '0' NOT NULL,
format enum('gif','jpeg','png','html','url') DEFAULT 'gif' NOT NULL,
url varchar(255) NOT NULL,
alt varchar(255) NOT NULL,
keyword varchar(255) NOT NULL,
bannertext varchar(255) NOT NULL,
active enum('true','false') NOT NULL,
PRIMARY KEY (bannerID)
);
CREATE TABLE clients (
clientID mediumint(9) DEFAULT '0' NOT NULL auto_increment,
clientname varchar(255) NOT NULL,
contact varchar(255),
email varchar(64) NOT NULL,
views mediumint(9),
clicks mediumint(9),
clientusername varchar(64) NOT NULL,
clientpassword varchar(64) NOT NULL,
expire date DEFAULT '0000-00-00',
PRIMARY KEY (clientID)
);
CREATE TABLE session (
SessionID varchar(32) NOT NULL,
SessionData blob NOT NULL,
LastUsed timestamp(14),
PRIMARY KEY (SessionID)
);
CREATE TABLE acls (
bannerID mediumint(9) DEFAULT '0' NOT NULL,
acl_type enum('clientip','useragent','weekday') NOT NULL,
acl_data varchar(255) NOT NULL,
acl_ad set('allow','deny') NOT NULL,
acl_order int(10) unsigned DEFAULT '0' NOT NULL,
KEY bannerID (bannerID),
UNIQUE bannerID_2 (bannerID, acl_order)
);


My opinion at the moment is that the problem lies not with the code above but with the recognition by mysqlc of the actual 'mysql <filename.sql;' command. I'm open to correction on this.
Reply With Quote
  #4 (permalink)  
Old 04-09-04, 16:23
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
You need to run this command:
mysql <filename.sql

from the DOS or COMMAND shell not within MySQL itself.
Reply With Quote
  #5 (permalink)  
Old 04-09-04, 17:21
DonalR DonalR is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
Tried running 'mysql <filename.sql;' from the command shell but just got the message 'bad command or filename'.

I keyed in cd c:\mysql\data\databasefoldername (created when I created the database) beforehand, and the filename.sql file is in that same directory.

Thanks for the suggestion, but no success yet...
Reply With Quote
  #6 (permalink)  
Old 04-09-04, 21:31
sqlhack sqlhack is offline
Registered User
 
Join Date: Dec 2002
Location: California
Posts: 32
you say you are running this from a batch file, could you post the text of that file also?
Reply With Quote
  #7 (permalink)  
Old 04-10-04, 05:46
DonalR DonalR is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
Sorry if I created the wrong idea - the only file involved is the filename.sql file.

I'm beginning to think that this is a Windows98 MySQL installation issue of some kind.

I've come across similar queries to mine elsewhere but no-one seems to have provided a silver bullet to fix the problem.
Reply With Quote
  #8 (permalink)  
Old 04-10-04, 06:12
DonalR DonalR is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
I've got it fixed!

I had been accessing the mysql command window using 'mysqlc.exe'.


Instead of using 'mysqlc.exe' to access the command window, I used 'mysql.exe', and it actually worked, using

source filename.sql;

So the solution is to use mysql.exe instead of mysqlc.exe to get the .sql files to run in Windows. I think this should be written large in the manual, to save newcomers like myself much hassle.

Many thanks to those who assisted.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On