MySQL: A Lot More Going for It Than No Price Tag (cont'd)

'Dump' Function Has Several Uses

The "mysqldump" function has options for locking tables prior to dumping, compressing the data on the way out, flushing the logs, and many other useful features. For quickly backing up and copying databases, however, there's another even faster utility called "mysqlhotcopy." It locks and flushes the tables and copies them to another location on the server (it doesn't work across remote servers). The syntax is as follows:

shell> mysqlhotcopy --user username --password=pass db1 /var/db/mysql/backup
(or wherever you want to store your backups)

It's possible to access MySQL in a variety of environments, including within the MySQL monitor, from the command line, as part of a Perl program with the DBI module, or with an ODBC-enabled middleware application such as Allaire Cold Fusion. Here's how a simple query to retrieve the contents of a table called fruit in a database called food might operate in a few of those environments:

Using the MySQL monitor:

mysql> SELECT * FROM food.fruit;

+--------+--------+----------+
| name  | color | quantity |
+--------+--------+----------+
| apple | red  |    10 |
| banana | yellow |    15 |
| grape | green |    50 |
+--------+--------+----------+
3 rows in set (0.00 sec)

The shell command necessary to access MySQL will vary depending on how the particular database and its permissions are set up. It's possible to specify a user and a password in the command if necessary. To take the above query and output the results to a file, use the following command:

shell> mysql --user username --password=pass -e 'SELECT * FROM food.fruit' > fruit.txt

fruit.txt now contains the three rows of data (without the column headers or reporting information) in tab-delimited format.

  
Next: Help With the DBI Syntax Lifting

1 Introduction 2 One Feature That's Missing 3 'Dump' Function Has Several Uses
4 Help With the DBI Syntax


Get Help - Search Tips
 

MySQL 3.23.33

Steve Renaker on Sleepycat's Berkeley DB

DevX e-Learning: Relational Database Concepts

DevX's Open Source Zone

DevX's Database Development Zone

DevX's Open Source.General discussion group

 TALK BACK
Have you ever worked with an open-source database? Has it served your purpose well? How does it compare with conventional DBs? Go here to start or join the discussion.
Click here to Join


Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers