473,403 Members | 2,293 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,403 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 2055
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.