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




Making A .bat File For The SOURCE Command


i have a sql script file that i normally
run from the mysql prompt using the command SOURCE

so i first i do
mysql> use tms;
then i do
mysql> source /path/to/file/script.sql;

how can i create a batch file for this process

my database username is root
and no password




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Source Command?
I have a users.sql file that I want to import into mysql. When I tried this
source F:gusers.sql

It gives me an error like this:

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 n
ear 'source F:' at line 1

ERROR 1102 (42000): Incorrect database name 'sers.sql'

but if I copy this file into F:data and use the command source F:datausers.sql
it worked fine.

Using Source Command
I'm using mysql 5.0 on a WinXP system.

I thought I could use the source command from the mysql> prompt to read text files containing sql statements to do things like create tables, but no matter what way I type my file name the source command says it can't open the file.

ERROR:
Failed to open file'"foo.txt"', error: 22

I've tried quotes, no-quotes, full path, 's, /'s.

SOURCE Command
i am new to mysql.i have a file full of sql statements
like
insert into mysql1.table1 values(4343);
.
.
.
now i want to run these statements and create my mysql table with data in it.
i was told to use a SOURCE command but iam having problems
from the mysql prompt i tried
mysql> source test.sql ( this is the file that has all the sql statements)
and i got "file could not be located" error: 2
my questions:
how can i syntactically specify the location of my file ?
will the SOURCE command serve my purporse?

Running MySQL's 'source' Command
I am having failures processing the following command and I wonder
if you can tell me what I must do in order to have success. When I try
to run source mysql_dump.sql.txt ==> it is a problem for me.

1) I put the file in /home/mlh/public_html/credifree/sql_script/.
2) I made that directory my current directory
3) I typed mysql and pressed ENTER
4) I then typed source mysql_dump.sql.txt and pressed ENTER

A bunch of error messages saying
ERROR 1046: No Database Selected
filled up the screen.

Well, of course there was no database selected. I do not yet have a
database. I thought the whole point of running
source mysql_dump.sql.txt
was to CREATE a set of database files on my linux box. Is that
incorrect? What must I do to avoid this error 1046?

And now, the last question...
Can you tell me where the database files will be placed when running
source mysql_dump.sql.txt as I described above from the same current
directory as described above? I do wish to KNOW in advance where the
files will be created.

Use A Source Sourcefile.sql Command Via The ODBC Connector?
I have a source file which creates and populates the database, I wolud like to be able to call this file from withing my application program using the ODBC connector. However when I try I just get error 1064.

My application is in java .. here is the code snippet concerned..
try {
            Statement st = con.createStatement();
            sqlquery = "source c:mysqlin
j_create.sql";
            rs = st.executeQuery(sqlquery);
            try {
                while (rs.next()){
                    System.out.println(rs.getString(1));
                }
                
            } catch (SQLException se) {
                System.err.println("reading SQLException: " + se.getMessage()) ;
                System.err.println(sqlquery);
            }
} catch (SQLException e){
            System.err.println("querying SQLExcpetion " + e.getMessage());
            System.err.println("err code " + e.getErrorCode());
            System.err.println(sqlquery);
}

Making A Mistake When Entering Mysql Command
Just wondering I'm going through the book "build your own database driven website using mysql and php.

While I was typing in a joke to enter into the database I messed up and don't know how to fix it


mysql>INSERT INTO joke SET
->joketext = "This is the joke I was entering",
->jokedate = 2004-03- 02";
->;
->c;
->/c;
As you can see I tried to get out of it but didn't know what to use so I just closed the command promp screen and began again. There has to be a better way.


Making A Command Line Connection To A Remote Mysql Server?
how do i make a command line connection to a remote mysql
server?

for local connections i know it is: mysql -u root dbname

how do i connect to a remote server with a password?

Errors With Source File
The file mysqlqui-win32-static-1.7.5-2.zip with file size of 37k
downloaded from http://www.mysql.com/downloads/gui-mysqlgui.html is
corrupt. Is there a mirror with a compiled windows xp compatible version
somewhere?

Pipe An Sql Source File In MySQL
Question: How can the command "source:data.sql" work. It says file cannot be found?

This is after I saved the files in E:Mysqldata

Background
--------------
I have just set up MySQL,PHP and Apache.

Since I can now manipulate data, both from command and using HTML.

Echo SQL Commands From A Source File
Running mySQL under Windows XP. Trying to debug a long input file of SQL statements (building tables and loading data from tab delimited text files) I want to be able to see the SQL commands that are executing in the output printed to the SQL command window so I know which error messages apply to which command. I have show warnings statements after each SQL statement at the moment so I see the errors/warnings, just not the command that generated the errors/warnings.

Is there an ECHO command or a flag when calling the script to get commands echoed as they are executed?

Save Command Output In Text File
How can i save output of "Select" command to a text file on server ?

Example :

SELECT email
FROM `forums`
into outfile "/text.txt";

^^ This does not works and gives this error on mysql prompt :

ERROR 1045 (28000): Access denied for user 'database_data'@'localhost' (using password: YES)

But if i just run this command on mysql prompt : It works ...

SELECT email
FROM `forums`;

It runs fine and displays result on screen.

But i want to save the output of the command in a text file on the server... Kindly let me know, right syntax to achieve it.

Command To Import Tabulated Txt File Into A Table
some of my clients are asking me to do a "import system" in my program, to they import xls data into their database...

So i know that there is a code to import tabulated txt files to a sql table.. but i didn’t know the command...

can someone help me? just say me the query command that I need to use pls -=^.^=-

Problems Executing .sql File From Command Prompt
I am having problems executing a .sql batch file from the mysql command prompt. I can run this file through SQLYog and i have no errors/problems but if i try and run the batch file through the windows command prompt (after connecting to the mysql database) i get a problem as soon as i try to change the delimiter back to ;

Has anyone else had problems with this?

Running Existing .sql File In Mysql Command Prompt?
I've seen "examples" of this in my book on MySQL, but it just shows the file on the prompt. It says that I can run an existing sql file - for creating a table - right from the prompt.

However, it doesn't really explain how to do this in detail. I've tried :

-h host - u user -D database -p < myfile.sql

but it gives an error. How do I point it to the right file on my system?

LOAD DATA INFILE Command To Import A Text File
I am using the LOAD DATA INFILE command to import a text file into
mysql.

However, there is much more text in the file than needed in my tables.
How can I make a selection from the text line. For example position 5 -
10 in field A, position 20-23 in field B, etc ...

How To Skip Column From A CSV File Using Load Data Infile Command
I have a CSV file with 111 columns but i want to load only 24 columns from it into my database.My database also has 24 columns.How can i do it with load data infile command.

Source For SQL
Is there a freely available source for a table populated with auto makes
and models by year? (Circa 1970 to present) Such a table would be useful
for databases used by car dealers, auto parts stores, repair shops, etc.

Making A Db
I just need to make a db with a password... but I do not know any commands nor where to find the ones I want.

Source Control
Does anyone know if there is a program (for windows) that can help us catalog our sprocs and table setups into source control?

SQL Source For A View
How do you obtain the SQL source that created a View?

I can Describe the view, but that doesn't give me the SQL that created it.

. . .

I should have searched the forums a little longer. The answer lies in the

SHOW CREATE VIEW viewName statement.

Source Duplicate
I created a database from a CSV file. Later, I recieve an updated CSV file. The second file contains most of the data from the first file, however some records have been removed and some have been added. Resourcing the database from the new CSV file is not an option because the unique key id column is shared with other tables. So my dilema is, how can I source in the new CSV file and exclude any rows that already exist? Also, how can I identify rows that no longer exist?

I have made a php script that fscanfs my CSV file then runs a seperate query for each row to see if each seperate record is there or not and generates a new sql script for removing and adding records. But, that means 1 query on the database per record, I have around 200,000 records. So this method is not worthwhile, I gave up after an hour of waiting on it.

I also tried using diff, but every time a new record is present it throws off the list and then im removing and adding records back and forth.

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).

Making The Right Subquery
I've been trying to wrap my head around this one for a while, and while it would be pretty easy to do using a loop in PHP I'd like to keep it in a single SQL statement if possible.

I have a table of comments, very much like you would store comments in for a blog. It goes something like this:

idCOMMENT | FK_LIST_ID | COM_Posted | COM_Comment
autoincrement| foreign key of post | Timestamp | Text for Comment


I only want to keep the most recent 30 or so comments on each listing so I need to create a statement that will delete any excess comments.
I could loop a statement like this in PHP:
DELETE FROM COMMENT WHERE idCOMMENT IN (SELECT idCOMMENT FROM COMMENT WHERE FK_LIST_ID=(variable from PHP) ORDER BY COM_Posted Desc LIMIT 30, 10^10)

But there will be thousands of listings, (it's and that's going to be rough on the server to make thousands of calls to it each night with the maintenance script. I think there must be a way to do this in pure SQL, just send one SQL statement to the server and that's it, but can't figure it out. Can you point me in the right direction?

Making A Column
ihave some Access background. I've created
a table for which I intended the email column to be the primary key,
but didn't specify it at creation. Now, I'm trying to figure out how
to specify it post facto.

Making Database
how do i make a database i cant make one i am trying to make a phpbb forum so i need help. all i have done is the install and the service config. but after the config shouldn't there be a mysql icon on the window control panel that creates db for you i dont have that.

Order Making
ORDER BY case when foto is not null THEN usuarios.ID_usuario END DESC, ID_usuario
could ordering results by case.., then etc.. be making queries slow?
Our db is really slow and we are trying to figure out why..

Making Querry
I was wondering are there techniques to optmize your queery?
Like someone told me if you do search on certian fields make them index keys. And in your SQL do not join too many tables etc.

Making Auto_increment
I did some searching and didn't come up with anything. Is there any way to make auto_increment go up more then 1 every time. Possibly make it use an equation and generate random stuff? Probably not but it's worth asking.

Making New Table
I'm a new to mysql, so exuse me if this is already asked (i just don't know what exactly i'm looking for)
This is what i would like to do: i'm creating new table and inserting new information to it, but i want to take one col from another table (searched by WHERE statment), how would i do it

Open Source Question
We are in the process of designing and building an application to collect a relatively small amount of discrete data (less than 100 data elements) from a potentially large group of industrial facilities. This system needs to be Open Source so other organizations can use the application by simply "plugging" in the app to do authentication/authorization (Open LDAP?) with a home-grown security design, access a web app (J2EE & probably Linux O/S), and MySQL as the backend. Certainly it's more complicated than what I describe, but I have my doubts of the capabilities of MySQL to be "robust" (yuk, I hate that word) enough to handle the potentially large number of simultaneous connections, among other issue including remote connection to Oracle DBs. I'm new to the organization and my boss's boss is the driving force behind the development. He's gung ho to get it built, but (beyond the political nightmare) I would like to "caution" him that the chosen platform is suspiscious at best.

How To Connect To An ODBC Source
I need help connecting mysql to an Oracle database. The Oracle database is set as an ODBC driver on my PC. I currently use MS access, connect via the ODBC connection and it runs great.

I now want to connect to this ODBC connection using mysql, but I don't know how. Can anyone get me connected?

Creating Data Source For My-SQL DB!
How can i create a data source for a My-SQL Database?

Stored Procedures And Source
I'm trying to script a stored procedure using a .sql file. Having no problems writing the same thing from the command line but I need to have all sp's under source control.

This is the syntax in the file I'm using:

USE db_1;

DROP PROCEDURE IF EXISTS test;

CREATE PROCEDURE test()
BEGIN
SELECT * FROM note;
END

Compile MySql Source

What do I need to compile MySql source?
I want to create MySql with SSL, and AFAIK i need to compile it.
Do I need MS Visual C++ or something like that ( I work in Delphi )?

Wrapping Database Source
Is there a wrap putility available for MySQL to wrap or obfuscate database source code? The reason for this being if I place a database off-site people who have access to the DB cannot steal your source.

Compiled Mysql From Source
I'm trying to install the DBD::mysql perl module, which, apparently, needs the mysql-devel stuff. If I compiled mysql from source, can I install the devel RPM without it messing up my settings? I have mysql in a non-standard directory.

Making MySQL Connection
I'm using DreamWearverMX, and try to establish the MySQL connection, but I'm confuse when it's asking for the connection name, MySQL server info, user name, password, and database. Where I can get these information to make the MySQL connection. I already build the "reservation" database, which contained fours tables, booking, clients, room and users.

Making A Best Topics Query
I have a rating system on a forum I'm building. Users can rate a topic either good or bad. For each Good rating, one point is added to the topic's score. For every Bad rating, one point is subtracted to the topic's score.

Each time a rating is made, several things are inputted into a MySQL table called ratings

rating_id
rating_date
rating_username
rating_topic
rating_value

What I want to be able to do is query this table to grab the highest rated topics and lowest rated topics in a given time period.....

Making A Field Unique
I have a table that has city names, some cities like Springfield occur in multiple states.

I use MySQL-Front for inputting my data. Anyone out there use this application too?

Can I get MySQL-Front to alert me when i have just entering an item that already exists with that field so I know to rename a city like Springfield-MO?

Making Database Backup
I have my website on a hosting compnay server. They are using phpmyadmin for MYSQL. I need to make a back of my database. I was told to use the option export, but I really don't understand it. When I click on "Export"  many options

I leave the default setting enter the file name and click "go" and endup saving a file with sql extension which look like this Code:

Making Categories From A Table
i have cell named age in my table.

i want a query like this.

ages between 18-25 will be in first column 26-30 in second 31-35 in third.

is it possible?

Making Secure Database
how would i go about making my database as secure as possible so users information is kept as safe as possible....

at moment i am using md5 encryption for their passwords... does any1 recommend anything else ?? and also in general to keep my data as safe as possible..... will web hosts deal with keeping mysql database secure or should i do sumting against it?

MySQL Not Making MYD Or MYI Files
I installed MySQL server 5.0 on my computer and have a problem. I create a database and create a table within it, then populate the table. At this point (on my old computer) I would copy the new database files to our webserver. However, on the fresh install, the folder only contains the .frm file, not the .MYD or .MYI files.

I'm looking in C:Program FilesMySQLMySQL Server 5.0data emp just for reference.

Making Values Null
Is it possible and safe to make a value into null in my database? My table contains rows with data and some collumns should be null but instead are like the following below

ID | Make
1 null
2 honda
3
4 null
5 Ford

So 3 should be null. I'm not sure why it is not showing up as not being null. Is it easy to change this across many rows and collumns

Making A Copy Of The Database
I need to create a copy of mySQL database on my dev machine (for development purposes), i use phpMyAdmin for db admin. the live db(from which i want to make a copy) uses phpMyAdmin also and i have access to it.

I tried to use phpMyAdmin feature that runs and populates the DB from .sql file, however the max file size is 2MB and mine is 17MB so that hasnt worked,
surely someone had to do it???? my db on my dev machine is mySQL as well, so it should be easy, right?

Making ODBC Work
When trying to set up programs (dbQwikSite, Adobe Designer) to work with
ODBC databases, I encounter the following during setup of the programs:
"it connects, but if I set the initial catalog to any database it says:
"Test connection failed because of an error initializing provider.
Catastrophic Failure."

But when I connect with the initial catalog field empty it connects
successfully.How do I fix this problem?

Making All Tables MyISAM
Is there a way to specify MyISAM for all tables in a given file rather
than having to specify it at the end of each table declaration. I think
this would make porting databases back and forth to MySQL somewhat easier
since including MyISAM as part of the table declaration is not compatible
with standard SQL syntax, so I would like to keep MySQL-specific stuff
separate from the rest of the SQL DDL file.

Making Columns In Mysql
I was wondering if there is a way to display more columns from one variable ?
For example take this quick database:
- Upload (the database),
- uplooad_files(the table),
- ID(the variable in the upload_files table)
- files(another variable)

Is there a way to display multiple entries in the files column in more columns on a web site ?

Can't Decide On MySQL Source Compile Or RPM
In about a week I need to install my new website which I have been working on for about 3 months. The website will run on a multiple of servers, but one of the primary servers will run as a MySQL database only server. In the past I have installed the MySQL server from yum (an update manager).

I have been looking at ways to improve performance on my database server and one option was to install the server from source. By using the correct compile flags and only compiling the extensions into MySQL that you need the result can be rewarding. But is it really?

The problems that I see with a source install is that updating it will take longer (since the database has to be compiled each time). This may get to be annoying each time a bug is found. Also I am kinda paranoid of some compile related errors.

What should I do? Just stick to installing from an update manager? Or should I install from source and take full control of my server.


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