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 Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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?
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.)
Batch File For Backup
Can I make complete Backup of a database (same as from MySQL Administrator) using batch file?
Batch FIle To Create Database
I am trying to create a batch file to create a database and populate it with create table statements. I can't figure out why it will not create the database and load the tables. I have the following in my batch file /mysql/bin/mysql.exe -vvv -u root -pcs3911 < C:mySql est.txt and the following is my test.txt file CREATE DATABASE 'lovettsite'; CREATE TABLE `applications` ( `username` varchar(255) NOT NULL default '', `firstname` varchar(255) NOT NULL default '', `middlename` varchar(255) NOT NULL default '', `lastname` varchar(255) NOT NULL default '', `current_address_line_1` varchar(255) NOT NULL default '', `current_address_line_2` varchar(255) NOT NULL default '', `current_city_town` varchar(255) NOT NULL default '', `current_state_province` varchar(255) NOT NULL default '', `current_zip_code` varchar(16) NOT NULL default '', `p.........................................................................
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:
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.
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?
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)
Execute A File
Is there a way to execute an SQL script from a file on disk from within MySQL? For example, I have a file containing a valid SQL script at C:david.sql. From within MySQL, I would like to dynamically execute the script contained within that file. Does there exist the syntax to do the equivalent of EXECUTE C:david.sql? I know I can make david.sql a stored procedure … and then CALL david(). I’ve done that. However, frank.sql happens to contain a CREATE FUNCTION statement, and MySQL won’t let you embed a CREATE FUNCTION statement within a stored procedure. If there’s another way to accomplish that end
Execute A Script File
I just update mysql server to version 4.1. And I try to use the following command: source C:/Program Files/MySQL/ MySQL Server4.1/data/wormlibrary/table_image.txt to execute a sql script file, but always get error like can't create table....(errno:150) This command and script file worked fine when I use version 4.0
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.
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;
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..
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?
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:
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
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.
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;
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.
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 ?
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.
See Feedback Message On Batch Mode
I am new on mysql. 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.
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 ;
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?
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) ???
Execute An SQL Doc
on freehostia.com i have my sql document, is there a way i can execute it, from browser without adding php?
How To Execute An SQL
Open your preferred sql administrator like phpMyAdmin and execute the included SQL file of this pack: The file name is star_product.sql I have acces to phpMydmin and currently involved in an Oscommerce website project and wish to add an "Add-on" to it. I am ok with changing structures to the tables within but have no experience of the above in bold.
Execute Scripts From VB.Net
I want to build a VB.NET update package for an application. So with each new release I want to update the client's database. I work with Stored Procedures, so in order to update the newest sp, I want to run a sql script from VB.NET on the client's pc. It is easy to run normal non-queries, but how do I execute a script?
How To Execute A SQL Script
I have successfully installed MySQL 5 and can also connect to the server. The issue is that my developer has sent me a copy of the database in .sql fromat (filename: abc.sql) and I do not know how to execute it so I can extract the tables. Can someone please show me the way?
Execute Trigger
i have created a procedure which generates a trigger on passing the table name to the procedure. now i want to execute this trigger which is currently stored in a user variable in the stored procedure. how do i execute the trigger directly from the procedure only or the procedure user variable.
GRANT EXECUTE
I'm running MySQL version 5.0.16-nt, and according to the documentation, the EXECUTE is a valid GRANT option that I can give. Every time that I try however, I get the following: Error Code : 1144 Illegal GRANT/REVOKE command; please consult the manual to see which privileges can be used What am I doing wrong here?
Execute Sql Script
I want to run a sql script (file) from the "mysql >" prompt and not from the command line. Is there any way to do this.
Execute Source
Is there anybody that knows as to run a query from DOS (I tried with --execute source filename.sql and the error meassege is ERROR1102: incorrect database name filename. When I enter mysql and use directly source filename.sql the query runs).
Execute More Then One Sql Statement
In MSDE I could do this "insert into tbl set fld = 1; insert into tbl set fld = 2". When I try that in MySQl, I get an error (below). 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 '; insert into tbl set fld = 2' at line 1 Does MySQl not support this?
EXECUTE Sp_rename
Hi, im coverting a mssql 2000 databse to mysql and ive good to a road block, that i cant seem to figure out how to get round. Part of the MSSQL 2000 code is Code: EXECUTE sp_rename And i cant seem to find an equivelant for mysql, i wa wondering if anybody knows of a way to get around this? All help is greatly appreciated Thanks Again Andy
Log And Execute Connection
1. How do I log only a certain connection? I know I can log the current connection using "T filename" option, but I am more interested in logging another connection knowing its ID. Perhaps I can switch the current connection to the one I want and use the T option? (which leads me to the next question)? 2. Is it possible to execute a query THROUGH ANOTHER connection using the terminal? Say I log into mysql, it assigns me my own connection, can I, from there, execute a query using one of the other current connections (if its status is "asleep").
Execute Time Of A Query
I'm running a SELECT * query on a table with over 3,000 rows. I need to know the execute time on the query. PHPMyAdmin shows it to me, but because they automatically add a LIMIT 0, 30 I suspect the time is only for those 30 records. It also has a feature to prevent web server timeouts that prevents me from setting the LIMIT to 0, 3100. BTW, I'm programming in PHP. Does the time to run the query get automatically passed when PHP sends the query to MySQL? <? PHP $Query = "select * from my_table where 1"; $Result = MYSQL_QUERY($Query); ?>
Execute Script Blocks
Is there any way that I can get code like this to run directly in the MySQL command line client (or similar tool) without using a wrapper proc/function? DELIMITER $$ BEGIN -- Example block of script code that uses an IF statement IF (1 + 1 = 2) THEN SELECT 'True' AS Message; END IF; END $$ I often want to execute script blocks directly during development when testing out code.
Incorrect Arguments To Execute
i am using the development release of mysql and have a PROCEDURE that executes a prepared statement. it works fine when i call the procedure but repeating it multiple times produces an "incorrect arguments to execute" error. replacing the prepared statement with a normal statement eliminates the error. is this due to the release or is a prepared statement not allowed in the procedure? i read somewhere that procedures are precompiled and hence will it be as fast as calling it multiple times without using the prepared statement?
Execute A Script In MySQL
I am renting space on 2 servers. On one server I created a script with sql's "create table .., insert into...". Now I want to execute this script on the second server. What is a syntax? I tried from telnet: dbname < file.sql where dbname is a name of my db and file.sql is a script, but I got message "syntax error".
Can't Execute Delete With The IN Operator
Lately I have been started using MySQL. I managed to create my database and tables. When I wanted to execute the following query: delete from adminpages where parentid IN ( select DISTINCT A.id from adminpages AS A where A.name='galeries' ); I have received the following error message: Error Code : 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 'select DISTINCT A.id from adminpages AS A where A.name='galeries' (0 ms taken).
Execute Script From A Trigger
Is possible to launch an external (php) script from a trigger? (If Yes, I'm looking for an example). Or a trigger can only execute a SQL command?
DBD::mysql::st Execute Failed
I am trying to store a binary image into a blob field and I am getting the following error: DBD::mysql::st execute failed: MySQL server has gone away at ...(file and line number here). I am following several online tutorials on the subject and each one (different implementations) fail at the execute line. If someone could tell me how to fix this I would greatly appreciate it. I have already tried commenting out the dbh->disconnect; line and it had no effect. Here is the code that is failing. use DBI; our $dbh = DBI->connect('DBI:mysql:pic_test:localhost','whateveruser','whateverpassword', {RaiseError => 1 }); my $sth = $dbh->prepare("INSERT INTO tbl_files (ImageColumn) VALUES (?)"); open(my $fh, 'input.jpg') or die $!; read( $fh, $var, -s $fh ); $sth->execute($var); $sth->finish; $dbh->disconnect; I am using MySQL server 5.0 on Windows XP and Active PERL 5.8.8.
Execute Mysqldump Command
I have a file containing the mysqldump command looks like this: mysqldump -t CPS_Trans Transactions --where:"(TerminalId = 06670002 and ..... I want to know how I can execute that file so that I can output th result to a another text file.
Timing A Trigger Or A Procedure To Execute
I need your help regarding how to time a sql procedure or a trigger to get executed ie., I would like to call the procedure or trigger automatically on a pariticular date and time after satisfying the required conditions.
Code Does Not Execute, But No Error Message Given
I used the info from Kevin's Database Driven Website book to construct the following code. It displays without errors. But when I enter info, the info is not entered into the database, and no error message indicates that anything went wrong. When I query the database directly, no data had been entered. I need another pair of eyes to look at this and tell me where I went wrong.
Average Query Execute Time???
I have a query taking about 4 sec that gets only 18 records.. That's not good. What can I do to speen up my Query? <CFQUERY DATASOURCE="#datasource#" NAME="qry_job_search"> SELECT DISTINCT (t1.JobPostId), t1.Actionlkp, t1.Date, tbl_job_posting.*, tbl_job_post_requirements.*, tbl_employer_info.*, tbl_employer_url.*, tblkp_employment_type.*, tblkp_education_exp_lvl.*, tblkp_salary_range.*, tblkp_employment_exp_lvl.*, tbl_job_post_location.*, tbl_job_post_job_categories.JobCat, tblkp_countries.*, tblkp_prefectures.* FROM tbl_job_post_history AS t1 JOIN tbl_job_post_location ON tbl_job_post_location.JobPostID = t1.JobPostID JOIN tblkp_countries ON tbl_job_post_location.CC1 = tblkp_countries.CC1 JOIN tblkp_prefectures ON tbl_job_post_location.CC1 = tblkp_prefectures.CC1 AND tbl_job_post_location.PrefectureID = tblkp_prefectures.ADM1 LEFT JOIN tbl_job_post_requirements ON tbl_job_post_requirements.JobPostID = t1.JobPostID LEFT OUTER JOIN tbl_job_post_job_categories ON tbl_job_post_job_categories.JobPostID = t1.JobPostID JOIN tbl_job_posting ON tbl_job_posting.JobPostID = t1.JobPostID JOIN tbl_employer_info ON tbl_employer_info.UserID = tbl_job_posting.UserID LEFT JOIN tbl_employer_url ON tbl_employer_url.EmployerID = tbl_employer_info.EmployerID JOIN tblkp_employment_type ON tblkp_employment_type.ID = tbl_job_posting.EmploymentType JOIN tblkp_education_exp_lvl ON tblkp_education_exp_lvl.ID = tbl_job_posting.EducationExpType JOIN tblkp_salary_range ON tblkp_salary_range.ID = tbl_job_posting.Salarylkp JOIN tblkp_employment_exp_lvl ON tblkp_employment_exp_lvl.ID = tbl_job_posting.EmploymentExpType WHERE t1.JobPostId NOT IN ( SELECT DISTINCT (JobPostId) FROM tbl_job_post_history WHERE Actionlkp =4 AND date = ( SELECT MAX( date ) FROM tbl_job_post_history WHERE JobPostId = t1.JobPostId ) AND JobPostID = t1.JobPostID ) AND HistID = ( SELECT MAX( HistID ) FROM tbl_job_post_history WHERE JobPostID = t1.JobPostId AND Actionlkp =1 ) AND Date >= ( curdate( ) - INTERVAL 30 DAY ) <CFIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A EQ 0 AND SESSION.CITY_A EQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' <CFELSEIF (SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A EQ "") OR FORM.PREFECTURE NEQ 0> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' <CFELSEIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A NEQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' AND tbl_job_post_location.PostCity LIKE '%#SESSION.CITY_A#%' </CFIF> <CFIF (SESSION.CATEGORY_A NEQ 1) OR FORM.CATEGORY NEQ ""> AND tbl_job_post_job_categories.JobCat = '#SESSION.CATEGORY_A#' </CFIF> <CFIF (SESSION.KEYWORD NEQ "") OR FORM.KEYWORD NEQ ""> AND t1.Actionlkp = 1 AND (tbl_job_posting.JobTitle LIKE '%#session.Keyword#%' OR tbl_job_posting.JobDescription LIKE '%#session.Keyword#%' OR tbl_job_post_requirements.JobRequirements LIKE '%#session.Keyword#%') <CFIF SESSION.KEYWORD NEQ "" AND SESSION.PGV NEQ "brief"> <CFSET SESSION.PGV = "detailed"> </CFIF> </CFIF> <CFIF SESSION.EMP_TYPE_A NEQ 1> AND tbl_job_posting.EmploymentType = '#SESSION.EMP_TYPE_A#' </CFIF> <CFIF SESSION.EXP_LVL_A NEQ 1> AND tbl_job_posting.EmploymentExpType = '#SESSION.EXP_LVL_A#' </CFIF> <CFIF session.SRT EQ "D"> ORDER BY Date DESC <CFELSEIF session.SRT EQ "C"> ORDER BY tbl_employer_info.CompanyName <CFELSEIF session.SRT EQ "L"> <CFIF form.country NEQ 0> <CFIF form.prefecture NEQ 0> <CFIF form.city NEQ 0> ORDER BY tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_countries.CC1, tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSEIF session.SRT EQ "T"> ORDER BY tbl_job_posting.JobTitle </CFIF> </CFQUERY> Can anybody see a shortcut to get the same results??
MySQL Execute An HTTP Request
Can the MySQL engine execute an HTTP request? Here is he scenario. I have a table that rarely changes but when it does I need to notify a web service. Is it possible to create a trigger that will make an HTTP call when fired and pass a couple of the field values as URL parameters.
Execute A Shell Command Inside SQL
I wonder if there is anyway you can run a shell command inside SQL. for example "SELECT * FROM table;execute shell command" I had googled around and didn't find anything.
|