Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Create And Run Batch File


I am using CentoS.

I have mysql installed.

I want to run around 60 queries.

Whats the best way to do it ?

If batch file then how to create batch file and how to run it in mysql environment ?




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Batch File
I am new to running batch files. Is there a way to loop through a results set in a batch file? I want to be able to create tables using table names that are stored in a table. I had hoped that I could query the table to retrieve all tablenames, then loop through this result set, creating a table with each tablename returned. (Table definitions will be the same for all tables created. Only the tablenames are different.)

View Replies !   View Related
Cant Execute Batch File
Hi new to this but pulled out nearly all my hair with this.
I got the test database open and I want to automate creating the menagerie table ( as in the tutorial ) so I download the textfile save it to c:/ and execute the command source c:/cr_pets_tbl.txt all I get is unable to open file error 22.
I have tried creating my own text file ( windows, notepad ) just containing the following
use test;
create table pets(name varchar(10),species varchar(8),born date);

simple as that then type in the consoe source c:/pets.txt;
unable to open file error 22 or sometimes error 2
tried enclosing filename in " and ' tried source= filename
tried . instead of source but nothing works.
using manual insert command or load data local infile works but not this, HELP.
Malcolm K.

View Replies !   View Related
Running MySQL Using A Dos Batch File
I am used to use MySQL on Unix, now I have to do some development for MySQL running on Windows machine. The following script works well in Unix but I am unable to run it on Windows. "MY_FLAG" is the one which is causing issue. Due to certain restriction in my framework, I can use the normal batch by supplying the .sql file while opening the mysql connection ( infact i need to run multiple source files) Code:

View Replies !   View Related
Using Batch-/cmd-file For Dumping Data
i want to build in data in my database that are written in single table dumps like [tablename].sql.

Each time it is nececery to use several files. And it is also nececary to do this using the command line because of the files are bigger than 1,5 gb
But i didnt find a way to transfere the needed commands into the mysql command line.

View Replies !   View Related
How To Execute A Batch Sql File Under Windows?
I have installed MySQL 5 in c:Program FilesMysql. I have a sql file named "books.sql" which is put in the subfolder in,it contains many statements that like "INSERT ... value ...".

my question is how to execute it? I try it, but failed.

One more question is how can I return from "->" to "sql>" promopt?

View Replies !   View Related
Connection String In A Batch File
I'm putting this connection string with the follwing batch file:

mysql --user=root --password=mypassword < batchfile.txt

It never executes the batchfile. How do I have to do it

View Replies !   View Related
Mysqlimport :: Run A Batch File To Import From CSV
I want to be able to run a batch file that imports a csv file to a mysql table. This seems like a perfect job for mysqlimport, but I have some questions first.

Here is what a typical line looks like:
00002,7/6/2005,7:37:15 AM,me@me.com,55337

My first issue is the date and time. I want these to be converted to mysql date and time format. Is there a way to do this directly with a mysql command?

Second issue is that I want to run mysqlimport on a machine that doesn't have mysql. It will connect to a machine that does. It seems that mysqlimport only comes if you install mysql, which I don't want to do on the client machine.

Third issue is that actual command. I want to be able to pipe out the output to a file. So overall the command would be import this csv file to this table, converting dates and times, and output the result to a text file.

View Replies !   View Related
Running Mysql Commands In A Batch File
I am trying to automate a mysql command to upload data everymorning on a windows server. I have created a .bat file and entered the commands to login to mysql but when it gets to the mysql prompt it fails to complete the rest of the commands.

cd
c:
cdmysqlin
mysql
TRUNCATE TABLE blah
LOAD DATA INFILE 'blah.txt' INTO blah
QUIT
exit

Is this possible?

View Replies !   View Related
Mysqld-nt Crashes When Executing Batch File In 5.03 Beta
I'm quite new to mysql but I had installed the 5.0.1 and 5.0.0a alpha under windows XP, and designed a little database for managing cards. To make some backup of this database I dumped it in a batch file. This file was working perfectly with mysql 5.0.1 and 5.0.0a.

When I try and execute my batch file, having previously created the database concerned, it crashes the mysqld-nt. On top of that the first table created in the database is listed but when a DROP DATABASE is issued it says that this table does not exist and then the command fails.

The database uses UTF8 and SET FOREIGN_KEY_CHECKS=0; is set in the begining of the file.

So I have two questions :

1- Can I force the database to be dropped or is it definitely corrupted?

2- Any clue on why the batch file crashes the server? (I'd be glad to send it is is a mere 250 ko when zipped)

View Replies !   View Related
Verifying Connection To MySQL Database In A Batch File
I have a Windows batch file that I'm using to call another batch file that connects to my MySQL database. The password is obtained from the user via a prompt and passed into the 2nd batch file where the connection to the database is made.

I'm having a hard time figuring out how to verify that the user entered the correct password. How would I go about testing the connection in the 1st batch file before calling the 2nd batch file?

View Replies !   View Related
Create My.cnf File
Sometimes during busy parts of the day, my site shows a 'Too Many Connections' error. I know it's something to do with the maximum default being 100, and that I need to change it in the my.cnf file. However I can't find the file. Can someone tell me, step by step, how to create the file?



View Replies !   View Related
Create/write To The File
I am working on Solaris and seem to get the following error
Cant create/write to the file '/home/dslab456/temp/tempoutput.lst'
As in windows i cannot specify which drive it is or so ? could anyone help me out with this ?

SELECT * INTO OUTFILE '/home/dslab456/temp/tempoutput.lst'
FROM stocklist_vokus s,p_tmpr p
WHERE s.STOCKLIST =p.stocklist_value
ORDER BY p.rid



Edited 1 time(s). Last edit at 02/12/2007 05:38AM by summer queen.

View Replies !   View Related
Can't Create/Write To File
#1 - Can't create/write to file 'AC Web Ultimate RepackServer mp#sql_dac_0.MYI' (Errcode: 2)

I am using Wampserver and I am creating the database using myphpadmin.

I installed the AC Web Ultimate Repack for World of Warcraft, but since then it has been uninstalled.

View Replies !   View Related
Create Table With SQL File
I'm fairly new to MySQL devlopment, and Im trying to create a table in and existing MySQL database using an sql file on windows platform ....

View Replies !   View Related
How To Create New Table From A Text File?
Is there a GUI utility which can create a new table in my mysql
database from a 50 million-record text file? I want mysql to get the
data into the database as whatever it can - varchar etc. I can change
columns later to double.... unless mysql is intelligent enough to see
that the field in the text file is numeric.

View Replies !   View Related
Create A Stop Word File
I need to change the stop word file used by the MySQL in fulltext seach.

The documentation (www.mysql.com/doc/en/Fulltext_Fine-tuning.html)
explains how to inform to MySQL the new stop word file through the
"ft_stopword_file" variable.

But I could not find any reference to the layout of this file, for
example, how to separate each stop word in the list?

Does someone have any experience on that?

View Replies !   View Related
Create Table From .MYD File After Crash
I accidentially deleted a table from my db, but I have a backup of the data in .MYD format, but I dont know how to recreate the table with the data to make it as it was before

View Replies !   View Related
How To Create A Table And Import A CSV File
Server version: 5.0.41-community-nt
phpMyAdmin - 2.10.2
MySQL client version: 5.0.37
Windows XP Professional on home PC
Linux shared hosting

I am a total newbie to MySQL and have never created a table. I'm using oscommerce and have the stock database that came with it and it is up and running on both my home computer and on the live server although the shop is not selling anything yet as it has no products other than the basic oscommerce product list. I'm hoping to do all this on my home computer before uploading to the live server which I do know how to do using import.

My supplier has sent me a load of CSV files with the headers as follows:
actionidcategory_pathnamedescriptionshort_descriptionimagespricetax_applicabledelivery_chargespecial_offerorder_locationnumber_in_stockproduct_weightproduct_codedoes_it_have_optionsname_of_optionstype_of_optionsoption_itemsprice_difference_of_option_items*EOL*

Total of 21 fields.

I found this information on how to upload CSV files but have no idea what it all means although I did try and failed.

To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV file.

You can then import it into a MySQL table by running:

load data local infile 'uniq.csv' into table tblUniq
fields terminated by ','
enclosed by '"'
lines terminated by '
'
(uniqName, uniqCity, uniqComments)
The fields here are the actual tblUniq table fields that the data needs to sit in. The enclosed by and lines terminated by are optional and can help if you have columns enclosed with double-quotes such as Excel exports, etc.

I created a table called mynewtable with 21 fields but haven't got a clue what I should put in all the fields so it will not let me save it.

View Replies !   View Related
Can't Create/write To File In C:windows
I installed the 3.51 ODBC driver on a new test machine that is re-imaged each night to a clean OS (Win XP Pro SP2). We place our developer daily builds on this machine and run some automation.

In the automation process, MYSQL statements are ran. The issue I get is that sometimes it stops with this error:

"Can't create/write to file 'C:WINDOWSTEMP#sql_1808_0.MYD' (Errcode: 13), #-2147217871"

or it will run right away, or sometimes it takes 3 tries before it finally gets past whatever it is choking on. I do not have MYSQL installed on that machine, only the driver.

I have given the "Everyone" account full permissions, but still no luck.

Any suggestions? The environment variable on the machine is set to C:WindowsTemp and it appears to execute some statements before, just is stops on some.

View Replies !   View Related
Create Image File From Blob Field
I has images saved on an mysql table as an blob field, but i could not recreate the image as file by selecting an specific record of this field.

View Replies !   View Related
Can't Create/write To File /var/run/mysqlid/mysqld.pid
I have installed mysql(mysql-standard-4.1.14-unknown-linux-gnux86_64-glibc23.tar) on linux.but when i tried to start mysql i am getting an error
can't create/write to file /var/run/mysqlid/mysqld.pid
can't start server can't create PID file :No such file or directory.

View Replies !   View Related
How Do I Create A Table For Holding File Permissions?
I am wanting to make file sharing website. So users can upload files and have control over who access the files. I am wanting to use MySQL for storing the users, passwords, home folders and access permissions for each file.

I want to make a table that has the userid and a list of all the files he can access. But I don't know how to make the table that would hold a list of files.

View Replies !   View Related
Importing Data :: Create And Insert Statements In A Text File
First day with mysql. I am working on Windows XP. I have a text file that contains sql commands - create table, insert into table and so on. I have created a database named rt and I want to run all the commands present in that text file in the rt database.

View Replies !   View Related
MySql OUTFILE, ERROR 1 (HY000): Can't Create/write To File
I have problems in exporting tables to a file in MySql using OUTFILE option. MySql machine is a remote one. I got the error

ERROR 1 (HY000): Can't create/write to file '/tmp/scshekaran/bcp_table.txt' (Err 2)

View Replies !   View Related
Batch Update
using mysql 4.1 i wish to update records using batch update but for a batch of 100, records and table having only 5000 records execution time is approx 2.4 sec i want to know whether this time is fine or i can further reduce it with some performance tunning ... the table which i am using is having 19 columns the update is on a single column ....

one more thing when i use the batch update for deletion batch size 100 along with update simultaneously the execution time increased for both...

View Replies !   View Related
Using Batch Mode
can someone show me the way of using batch mode?
what is the syntax of it?
what should i do for the first step?
can someone tell me about that?

View Replies !   View Related
Using Batch Files
I have a small problem with using batch files (platform: Windows XP). The problem I have is that I do not want to place and call all my db batch files from within BIN folder, but rather from, say c:a1a2a3. Calling a batch file in Windows like this is not an issue:

mysql>source c:/a1/a2/a3/test.sql;

Then, you can call test.sql from test2.sql, for example, by the same line of code:

source c:/a1/a2/a3/test.sql;

Is there any way to keep the base direcory, i.e. c:a1a2a3 in some sort of environment or whatever variable and then use it in the parameter passed to the source command.

I have experimented with user-defined variables to no avail:

SET @BASEDIR = 'c:/a1/a2/a3/test.sql';
SOURCE @BASEDIR;

View Replies !   View Related
Batch Load
I have a long list of files in a directory with one file containing the sql statements and a second file containing the tab separated data. Such as:

a.sql
a.txt
b.sql
b.txt
...and the list goes on.

I'm trying to source sql files and insert the txt files into the tables but I'm not sure how to batch-process them..

View Replies !   View Related
Batch Mode
I understand that to use batch mode it is necessary to put the commands you want to run into a file before telling MySQL to read its input from the file, but how do I create the file and what do I create it in? Also, I'm not really sure how you would then tell MySQL to read it.

View Replies !   View Related
Create Virtual Table During Query Or Load Table To Memory From Text File
I have access to my application database via a secure link, so I cannot link a local database to it, only run queries on the remote server and download the result.

The database is missing some useful information, and I cannot add a table at this stage. I would like to achieve the result by creating a virtual table or the like. ...

View Replies !   View Related
Consecutive Ids In A Batch Insert
I am new to mysql and would appreciate any advice that you have to
offer.
I am attempting to batch insert 100 rows into a table, and I need to
know the 100 id's of all the inserted rows.

I know that I can find the id of the last inserted row despite my app
being multi-threaded, since the select last inserted command is
connection-specific.

Given the id of the last inserted row, can I back out all the ids of
the inserted rows? Are the inserts consecutive in an auto-increment
table?

If not, I will be looking to lock the table during inserts, but that
seems very sub-optimal.

View Replies !   View Related
Batch Mode Problem
I am having a problem with 2 sql statements in 1 batch file. Only the last
statement executes. If I separate the statements into individual files they
work fine.

Are you only allowed 1 statement per file?

Here is the contents of the batch file:
insert into monlog (monlog_locno, monlog_custno, monlog_time,
monlog_inputdate, monlog_errno) select loc_no, loc_custno,
(hour(now())*60)+minute(now()), now(), 200 from loc where
loc_next+29<(hour(now())*60)+minute(now())+30 and loc_errno>=200 and
loc_errno<=249;
update loc set loc_errno='250' where
loc_next+29<(hour(now())*60)+minute(now())+30;

View Replies !   View Related
Execute Batch Mode
I want to execute the queries wriiten in a .sql file in a single attempt using the batch process of mysql.Since I don't have a good grip over the database systems, I am confused how should I go for it..

View Replies !   View Related
Mysql Batch Question
I'm writing this here because it's related to mysql. I'm using Mysql with PHP and because Mysql 4 doesn't support stored procedures, I would like to run several scripts from one database connection. In running a multi-line sql.txt file externally I can do this by delimiting the statements with a semi-colon so I tried to do the same:

$strsql = "";

$strsql = "delete from tbl1 where tbl1ID = '1';";
$strsql = $strsql . "delete from tbl1 where tbl1ID = '2';";
$strsql = $strsql . "delete from tbl1 where tbl1ID = '3';";

$result = @mysql_query($strsql, $db);

I'm not getting an error; the sql scripts simply won't run.

View Replies !   View Related
Consecutive Ids In A Batch Insert?
I am attempting to batch insert 100 rows into a table, and I need to know the 100 id's of all the inserted rows.

I know that I can find the id of the last inserted row despite my app
being multi-threaded, since the select last inserted command is
connection-specific.

Given the id of the last inserted row, can I back out all the ids of
the inserted rows? Are the inserts consecutive in an auto-increment
table?

If not, I will be looking to lock the table during inserts, but that
seems very sub-optimal.

Running mysql 5.0.24

View Replies !   View Related
Doing A Batch Find And Replace
I'm using a media player called amarok which stores data on media files (such as last date played, play count, etc) in a MySQL database.

I'm setting up a new system and want to transfer my database, but I'm also going to change the file structure on my new system.

In order for the new system to be able to use the database I think I need to find a way to change all of the old directories to the new directories in the MySQL database.

So for example,
There's a table called 'directories'
In 'directories' theres a field called 'dir'
Right now a typical entry of 'dir' looks like "./music/collection/[artist]/[album]"
and I'd like to replace the ./music/collection part with a different path for every entry.

View Replies !   View Related
Getting Error In Batch Update
I am using Mysql 4.1.13 with Tomcat5 and Connector mysql-connector-java-3.1.10. When I try to update the table in batch mode sometimes( When server is idle for a long time) get following error. Code:

View Replies !   View Related
How To Batch Rename Tables?
I have a few Wordpress databases that need to have the tables renamed. I would like to make a script to batch process this.

Currently the databases have names like this:

wp_j1rry4_comments
wp_j1rry4_links
wp_j1rry4_options
wp_j1rry4_postmeta
wp_j1rry4_posts
wp_j1rry4_terms
wp_j1rry4_term_relationships
wp_j1rry4_term_taxonomy
wp_j1rry4_usermeta
wp_j1rry4_users

How could I change them to have their names like this:

wp_comments
wp_links
wp_options
wp_postmeta
wp_posts
wp_terms
wp_term_relationships
wp_term_taxonomy
wp_usermeta
wp_users

I found this webpage that does something similar but they are adding a prefix to the table name, I want to take characters away.

View Replies !   View Related
Mysqldump :: Bin/mysqldump: Got Error: 1: Can't Create/write To File
When executing the following command:

bin/mysqldump -u root -p -T /Users/bj/Desktop/ tfc

The following error appears:

bin/mysqldump: Got error: 1: Can't create/write to file '/Users/bj/Desktop/acts.txt' (Errcode: 13) when executing 'SELECT INTO OUTFILE'

However, it does write the 'acts.sql' file which one of the files in the tfc database.

I suspect this has something to do with permissions, but even when I run this as 'unix root user' I get the same error.

View Replies !   View Related
Tabs Missing In Batch Mode
in a shell script of mine I'm executing a mysql SELECT in batch mode. I
want to use the return value for other sql statements.
The problem I'm facing is that the tabs, which seperate the columns
from each other, are missing in the output.
What am I doing wrong?

#!/bin/sh
QUERY="select id, i.handle from idmap i, person p where
i.handle=p.handle and email="$1""
mysql mydatabase -pmypassword -N -B -e "$QUERY" | while read line ; do
personid=$(echo $line | cut -f1) ; handle=$(echo $line | cut -f2 ) ;
echo $handle ; done ;

View Replies !   View Related
See Feedback Message On Batch Mode
I wrote a perl program to update/insert mysql
database. It worked fine but I could not see the feedback message to
show how many rows updated or inserted. I can see that if I issue SQL
commands interactively.
BTW, what's the easiest way to check return code from SQL commands in
perl. I use korn shell script to invoke perl script that does SQL
stuff. I need to pass the return code back to shell script.

View Replies !   View Related
Using Parameters In Mysql Batch Mode
I'm calling a "mysql" command in a shell script, like:
"mysql <toto.sql"

and I'd like to transfer shell parameter to "toto.sql".

View Replies !   View Related
Prepared Statements (for Batch Inserts)
I am looking into using prepared statements as a possible performance optimisation in my application. I am currently using a batch insert statement:

insert into mytable values (d11, d12, d13), (d21, d22, d23),...,(dn1, dn2, dn3)

The database insert/select logic is multi-threaded. The number of rows that are to be inserted in the batch is variable. I am using Connector/NET to access MySQL from the application.

MySqlCommand as far as I can tell is not thread safe which means creating a new command instance for each statement the application needs to execute for each thread.

How does this affect prepared statements ? Are they automatically cached under the hood so if a new MySqlCommand is created using a previosuly prepared statement, is this handled so as to prevent "preparing" the statement again ? Do I need to cache each MySqlCommand instance for each unique prepared statement ?

What performance gains if any will I get if I use prepared statements instead of non-prepared statements for batch inserts as shown above?

How would I define the prepared statement parameters for a batch insert with a variable number of rows ?

View Replies !   View Related
Batch Query Or Large List Of IN() Arguments?
I'm receiving a potentially large list of productID numbers from an external data source.

Each productID has a number of partID's associated with it and those partID's are stored in my database.

I would like to create a list of products sorted by the number of parts each has.

If I only have one table called "part" which stores a partID and its associated productID, which of the following methods would be more efficient assuming the application and DB are on the same server.

Option A)

SELECT productID, Count(*) counter
FROM part
WHERE productID
IN(large list of productID's received, maybe 1 or >10000)
GROUP BY productID
ORDER BY counter DESC
LIMIT ?, 10

Option B)

Execute a batch query of prepared statements (SELECT COUNT(*) FROM part WHERE productID=?) for each product in the received product list then sort the returned results in the Java app that is making the query.

Option C)

???

View Replies !   View Related
Running A Sql Batch Script From The Linux Command
s this possible?

I want to write a command script which i want to put into a cron job which will download a db backup from cpanel. then i want to unzip it, and run the sql file, so keeping the database on the mirror machine up to date.

So what i have is:

#get the database
wget -v --http-user user --http-pass pass https://www.site.com/path/to/cpanel/backup
#move to backups folder
date=`date -I`
mv -fv ./mysqldump.gz /home/user/dbbackup/$date.gz
now what i also want to do is:

mysql -uuser -ppassword
u database
set foreign_key_checks = 0;
. mysqldumpfile.sql
set foreign_key_checks =1;
exit
is it possible to do that last bit from the command-line? as far as i know, a shell script can't run commands to mysql?

View Replies !   View Related
Batch Mode Feedback Of "mysql" Command Line Tool
while writing a bash shell script to backup some databases and I am having slight problems with the mysql command line tool's feedback.

Here goes command line:

#!/usr/bin/env bash
mysql -ubackup -e "UPDATE `mydb`.`sysvar` SET `val`='backup' WHERE `var`='updateState' AND `val`='0';"

The backspaces are nescessary for the shell, otherwise it'd interpret whatever is inclosed in --> ` <--- as command.

The problem is, I need to know wether a line has changed or not. The command always returns 0 (that is a success in Unix/Linux) if it was successfully executed, no matter wether or not a line had been changed, and produces no output at all.

Could anyone tell me how I get that info?

View Replies !   View Related
If I Create An Index With Multiple Fields Do I Still Need To Create Individual Ones?
I have a table where the name field can only contain duplicates when the user_id field is different, so I create an index with user_id,name. Now I was wondering if I want to search just for the user_id or the name field individually does this dual field index count, or should I create another index for the user_id and the name?

View Replies !   View Related
How To Create Index When Doing 'create Table As Select'
Code:
Create mysqlorary table mysql
AS SELECT
Name
FROM
EmployeeList
WHERE
Dept = 'XXX'

I would l ike to create an index on the field Name of the mysqlorary table mysql. I wonder if I can create the index on the fly by adding sth in the above statement.

View Replies !   View Related
How To Create Different Namespaces When Using CREATE VIEW?
I'm doing a triple join between tables which have similarly named fields...I was hoping that when using CREATE VIEW, the result would be a table with fields such as a.field, b.field, c.field...but I get an error "Duplicate column name 'field'"

...How can I get around this besides changing the name of the duplicate field in each table?

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved