473,372 Members | 1,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

About MySQL scripts

Hi,
I am new to MySQL. I want to create a script file which will include a
number of commands and execute it, just like we do in Oracle. Can any
one tell me how to do it?
Suppose I want to create a script called "temp" that will contain say 4
create statement. I want someone to show me how to create that file and
execute it. And how to capture the output in a separate file like we do
in Oracle. And what should be the extension of the souce file.

Thanks.

Apr 1 '06 #1
1 2051
Karuna wrote:
Hi,
I am new to MySQL. I want to create a script file which will include a
number of commands and execute it, just like we do in Oracle. Can any
one tell me how to do it?
The MySQL software comes with a utility that serves as both an
interactive shell (analogous to Oracle's SQL*Plus) and a tool to run
scripts containing SQL commands.

Read this documentation page and its sub-pages:
http://dev.mysql.com/doc/refman/5.0/en/mysql.html

Specifically, executing SQL script files is documented here:
http://dev.mysql.com/doc/refman/5.0/...-commands.html
http://dev.mysql.com/doc/refman/5.0/en/batch-mode.html
Suppose I want to create a script called "temp" that will contain say 4
create statement. I want someone to show me how to create that file and
execute it. And how to capture the output in a separate file like we do
in Oracle.
You can capture output just like any other command at the shell level,
with the ">" output redirection feature.

You can also use the "tee" command in your script to specify the output
file.
http://dev.mysql.com/doc/refman/5.0/...-commands.html

You can also use the --tee='filename' option to the mysql command.
Options are documented here:
http://dev.mysql.com/doc/refman/5.0/...d-options.html

Create the file with a text editor. Alternately, create the file by
capturing the output of MySQL's "mysqldump" command-line tool, which
serves as a database backup utility. The output of mysqldump is a SQL
script that contains the CREATE and INSERT commands necessary to
recreate a database. You can run this script with the 'mysql' utility
as described above.
And what should be the extension of the souce file.


The extension is not important. My habit is to use ".sql", but the
mysql client utility doesn't require any specific extension on the file.

Regards,
Bill K.
Apr 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
Hi, I am running Debian 3.0r1 with Apache 1.3.27, MySQL 3.23.49 and PHP 4.3.3RC3. I installed Apache and MySQL when I originally installed Debian and these work fine. I recently wanted to run...
0
by: Enrique Sanchez Vela | last post by:
Hi, Would anyone explain me why the startup scripts check for command line arguments and the contents of /etc/my.cnf right after setting the env variables such as basedir, pid-file and so? ...
2
by: Sean Berry | last post by:
I have downloaded the source code for mysql-3.23.58. I unzip and untarred it and ran $ ./configure --prefix=/usr/local --localstatedir=/usr/local/mysql $ make $ make install $...
2
by: adnan alsamari | last post by:
Hi, I can only access mysql through the root by typing mysql -u root -p. But when I use any other user to connect to mysql I get the access denied error message. Mysql is installed on windows xp. ...
2
by: Wes Graves | last post by:
Hi there, I have a few MySQL scripts that I need to run in SQL Server. However the syntax is just slightly different and I was wondering if there is a tool out there that can quickly convert...
3
by: Yevgeny Ioffe | last post by:
Hello, I am working on transferring MySQL dumps to PostgreSQL. I have tried the scripts I found in relevant section of PostgreSQL documentation website, but they all give me various parsing...
1
by: Lennie De Villiers | last post by:
Hi, I'm running PHP 4.4.2 and mySQL on MS Windows XP Home Edition in IIS 6.0. When I try to connect to mySQL from PHP I get the following error message: Warning: mysql_connect(): Client does...
7
by: Paul | last post by:
I recently installed php 4.4.4 using windows binaries on Windows XP Pro. I also installed MySQL 4.1. I usually use Pear DB but I tried MDB2 and it worked fine until a client uses a different...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.