MySQL is a relational database management system that runs as a server allowing multi-user access to a number of databases.
Using an online database allows information to be stored, updated and displayed by web pages.
MySQL uses Standard Query Language to perform operations on databases. Queries are passed to MySQL using either ...
The MySQL Command Interpreter on your own machine or via Telnet on a remote machine (if MySQL is installed).
PHP library functions that interact with MySQL.
When MySQL is used on a web site it's the PHP library functions that are used and MySQL queries are passed as arguments of these functions (functions are covered in the PHP User-Defined Functions tutorial).
This tutorial starts by using the MySQL Command Interpreter to demonstrate MySQL queries before moving on to how to use the queries as arguments in PHP functions.
Installing MySQL
If you have access to a hosting package that has PHP and MySQL installed then you will be able to develop and run your scripts there - and this is ultimately where you will wish to run them.
However, it's nice if you can run them on your own machine whilst you learn and develop them and this means installing MySQL on your own machine. Before you do this you will need to install Apache and PHP - you'll find some help in the PHP Running a Script tutorial.
When you have Apache and PHP installed then go to MySQL Downloads and download the latest version appropriate to your system and follow the installation instructions.
Note: When you install MySQL you will be prompted to choose a password. Make a note of this password - it will be required when you connect to MySQL using PHP.
The MySQL Command Interpreter
Assuming you have Windows and have successfully installed MySQL then you can access the MySQL Command Interpreter via the MS DOS Command Prompt by going to Start > Run and entering cmd.
This will open the Windows command line interface and will show a Windows copyright message followed by an MS DOS prompt that displays a path that will probably be something like C:\Documents and Settings\User>
By default MySQL is installed in C:\mysql\bin so change the path by entering cd C:\mysql\bin and hitting Return.
To start MySQL enter mysql and hit return. You should now see a MySQL message with the MySQL prompt below it.
The MySQL Prompt
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.14-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer
mysql>
It's from the MySQL prompt that all your MySQL commands will be entered.
Exiting the Command Line
To exit MySQL enter 'exit' and hit Return. This will return you to the MS DOS prompt where you can again enter 'exit' and the window will close.