Implementing Database in MySQL
Implementing Database in MySQL – Part 1
Division 4
Forward: This part of the series is an introductory tutorial on implementing database in the software package, called MySQL.
By: Chrysanthus Date Published: 6 Aug 2012
Introduction
In the three divisions, we learned how to design a database. After designing a database, you have to implement it. Implementing means you have to code it for a particular Database Management System (DBMS). There are many database management systems in the market. MySQL is one of them. This series deals with MySQL 5.1.
Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.
Operating System for this Series
The rest of this series is written for the Windows Operating System (Windows XP SP2 and higher). However, almost all the features in this division are applicable to MySQL used in other operating systems.
Installation
Download the free version of MySQL 5.1 from the Internet; search the net for it. The file I downloaded for my system is, mysql-essential-5.1.40-win32.msi. Depending on the microprocessor of your computer, you may have to download a different file.
To install MySQL 5.1, just double click the file, mysql-essential-5.1.40-win32.msi. Allow the default settings. In the installation process, a window will appear with the title, “Configure the NySQL Server Now”. Click, Next in this window and continue to allow the default settings. Along the line another window will appear asking you to type and confirmed password. Type the password, “sql”, without the quotes in the two places. Continue with the default settings till the installation is finished.
For you to create and use a database, you need software called a database server. With MySQL, you need to start the server and connect to it using a user name (ID) and a password. Then you can create and/or use your databases. When you have finished your work, you quit the server, thereby disconnecting from the server.
Command Prompt
We shall use the command prompt (DOS window) to start and stop the server (see below), and also to create a database. MySQL has other ways to start and stop the server, but I believe that a serious beginner should start with the command prompt. In that way he would have a better understanding of what is going on. You access the command prompt in Windows XP as follows: Start>>All Programs>>Accessories>>Command Prompt.
UserID and Password
With the above installation, your username (userID) is, root. This means you are the Database Administrator (DBA). You have total control over the server and any database you create. You password, which is what you typed in is, sql. You could use a different password if you wanted to, but allow this one, for these tutorials.
SQL
SQL stands for Structured Query Language. It is a computer language that is used to create a database and its tables. It is also used to retrieve information from the database. Each software manufacturer such as MySQL has a slightly modified version of the standard language. In this series we shall learn SQL of MySQL. Most of the things, learned in this series under SQL are applicable to other manufacturers such a Microsoft. SQL consists of a set of statements, collectively called the SQL Statements.
Note, each SQL statement ends with a semicolon.
- While at the command prompt window, go to the root directory by typing the following command and pressing the Enter Key:
cd c:\
- Type the following and press Enter (do not forget to type the quotes). What you have in quotes is the path to the executable file, mysql.exe. In your computer the path might be slightly different:
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" -u root -p
With that command, you have started the server, with the userID, root. –u and – p in the command are called switches. –u is for the userID and –p is for the password. It will ask you for a password on the line below. As you type the password, you see asterisks in place of the password letters, you type.
- Type the following for password and press Enter:
sql
You should see text like this:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 25338 to server version: 5.1.53-standard
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>
The mysql> is called the MySQL prompt. It shows that the MySQL server is active waiting for you to type your SQL statements to do whatever you want with a database, or to create one. When you type your SQL statements at this prompt it goes to the server. The mysql prompt is actually a utility (tool) that allows you to send SQL statements to the server. We shall create a database later on.
For now let us quit the server thereby disconnecting from the server and stopping any database that might have been started.
- Type the following command and press Enter:
QUIT
It should display, Bye, confirming that you have closed everything.
Well, we have seen how to connect and leave the server. Let us take a break here and continue in the next part of the series.
Chrys
Related Links
Major in Website DesignWeb Development Course
HTML Course
CSS Course
ECMAScript Course
NEXT