|
Home >> FAQs/Tutorials >> MySQL Tutorials >> Index
MySQL FAQs - Command-Line End User Interface mysql
By: FYIcenter.com
Part:
1
2
3
4
(Continued from previous part...)
How To Run "mysql" Commands from a Batch File?
If you have group of "mysql" commands that need to be executed repeatedly,
you can put them into a file, and run them from the file in "mysql" batch mode.
Here is a batch file, \temp\links.sql, contains following commands:
USE test;
INSERT INTO links VALUES (10, 'dba.fyicenter.com');
SELECT * FROM links;
To run this batch file, you need to follow this tutorial:
>cd \mysql\bin
>mysql -u root < \temp\links.sql
id name
1 dba.fyicenter.com
10 dba.fyicenter.com
How To Return Query Output in HTML Format?
By default, "mysql" returns query output in text table format.
If you want to receive query output in HTML format, you need to use
the "-H" command option. Here is a good tutorial exercise:
>cd \mysql\bin
>mysql -u root -H test
mysql> SELECT * FROM links;
<TABLE BORDER=1><TR><TH>id</TH><TH>name</TH></TR>
<TR><TD>1</TD><TD>dba.fyicenter.com</TD></TR>
<TR><TD>10</TD><TD>dba.fyicenter.com</TD></TR></TABLE>
2 rows in set (0.00 sec)
How To Return Query Output in XML Format?
By default, "mysql" returns query output in text table format.
If you want to receive query output in XML format, you need to use
the "-X" command option. Here is a good tutorial exercise:
>cd \mysql\bin
>mysql -u root -X test
mysql> SELECT * FROM links;
<?xml version="1.0"?>
<resultset statement="SELECT * FROM links">
<row>
<field name="id">1</field>
<field name="name">dba.fyicenter.com</field>
</row>
<row>
<field name="id">10</field>
<field name="name">dba.fyicenter.com</field>
</row>
</resultset>
2 rows in set (0.00 sec)
Part:
1
2
3
4
|