473,762 Members | 8,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2076
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
2785
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 some PHP scripts on my web server that talked to a MySQL database. I installed php4 and php4-mysql using apt-get. Unfortunatly I can't get the scripts to work. I keep getting the following error: Fatal error: Call to undefined function:...
0
1917
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? if the MySQL code and scripts are expected to be on a specific hardcoded location (yeah, right we could specify this at build time) why bother supporting
2
1550
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 $ ./scripts/mysql_install_db I have a user mysql, and group mysql. I ran
2
2977
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. I looked up information online to solve this problem and saw that there are some scripts that i may be able to run in order to fix the problem. But I am not sure how to handle those scripts since they are only made for unix systems. I tried to...
2
16052
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 these scripts so that they will work with SQL Server? Anyone have any ideas (other than manually converting them)? Thanks,
3
1551
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 errors. What am I to do? Thanks!
1
1794
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 not support authentication protocol requested by server; consider upgrading MySQL client in D:\Work\LIVE WORK\Gafachi Clone\www\dbconnect.php on line 9
7
2496
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 version so I reverted back to straigh PHP mysql function calls. I use this code: $link = mysql_connect('localhost', 'username', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); }
22
2736
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 things. So, in instances where I list, for example, the latest weblogs. I list the headline of the weblog, the date and the name of the member who wrote it. Now, the name isn't just "Smith", but rather Smith's online status, his nick and his...
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9812
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7360
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.