|
Introduction
This article describes how to install and run MySQL from the Command Line in a DOS type window running under Windows XP. The MySQL product is a popular open source database which is available at zero price under the GNU General Public License (GPL).
MySQL has two main parts, a back end which does all the work and a front end that allows users to create, read, update and delete information. The back end Database Server holds the database tables and executes SQL commands. It gets commands from one or more front end Client Programs. They provide the user's interface to the Server. A basic form of front end Client provides a command line interface where SQL statements can be entered via a DOS window. The MySQL Control Center which can be downloaded separately, provides a more sophisticated windows based client interface.
Installation
Download MySQL from http://www.mysql.com/ and unpack the zip file to "c:\mysql". There is no Windows install program to worry about.
Start the Database Server
Create a command line window and set the Database Server going:
cd c:\mysql\bin mysqld-max --standalone
No response is given after the command. However, a log file is created in the "c:\mysql\data" directory called mymachine.err that contains the expected response. Where "mymachine" is the computer name.
The command line window can be closed and the process will run in the background. You can check this is working by running the Windows XP Task Manager and finding an image name called "mysql-max.exe".
Using the Client Program
To get help on the Client Program use:
c:\msql\bin\mysql --help
Set the MySQL client running by typing:
cd c:\msql\bin
mysql
The prompt changes to "mysql>". This shows that you are in the Client Program. SQL commands can now be entered and executed. For example:
select version(), current_date;
select user(), current_date;
show databases;
use test;
show tables;
Note that the user is shown as "ODBC@localhost". To come out of the Client Program type:
quit
Using the Control Center
Double click on the MySQL Control Center icon provided on the Desktop. In the Console Manager window click on "File" -> "New". Enter "ODBC@localhost" in the Name field and click on the "Add" button.
The Console Manager should fill with details under the Property and Value columns. The Messages area should then display "Connection added successfully".
In the Console Manager window click on the SQL button in the Tool Bar to create a Query Window. Enter "select version(), current_date;" in the "Query 1" area and click on the execute button on the Tool Bar. The result is displayed underneath.
Simply close the Console Manager window to shut it down.
Shuting Down the Database Server
To terminate the Database Server process from the command line move to the "c:\mysql\bin" directory and type:
mysqladmin -u root shutdown
|