MySQL Tutorial

Getting Started

When you start using MySQL, you use a command prompt to enter the SQL statement. The statements can be quite lengthy, and a pain to modify. The simplest way of using MySQL is to use files containing the SQL statements to perform. For example, if you want to create a table called, search, you could create a file called called, createSearchTable.sql and load this file from the command prompt rather than type in a lengthy SQL statement to create the table.

Loading SQL Statements from a File

The SOURCE command is used to load the file from the command prompt.

mysql> SOURCE createSearchTable.sql

The sequence \. is a shorcut name for the SOURCE statement. The following does exactly the same thing as the above SOURCE statement.

mysql> \. createSearchTable.sql

Logging Output

The TEE statement may be used to log output from your SQL statements to a text file. The following command copies all output to the file log.txt so you can examine the results of running your queries.

mysql> TEE log.txt

You can turn off loging using the NOTEE statement.

mysql> NOTEE

You might also like...


About the author

Gez Lemon United Kingdom

I'm available for contract work. Please visit Juicify for details.

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.” - Dennis Ritchie