Monday, April 27, 2009

MySQL Table Types

MySQL supports several table types which allow to user to optimize the database. There are the following table types are available in MySQL:

1. ISAM
2. MyISAM
3. InnoDB
4. BerkeleyDB (BDB)
5. MERGE
6. HEAP

ISAM: ISAM had been deprecated and removed from version 5.x. All of it functionality integral replace by MyISAM. ISAM table has a hard size 4GB and is not portable.

MyISAM: MyISAM table type is default type when you make table. MyISAM table work very fast but not transaction-safe. The size of MyISAM table relies upon the operating system and the data file are portable from system to system. MyISAM tables support full-text indexing and searching feature.

InnoDB: InnoDB table are transaction safe, holds row-level locking and foreign keys are supported in this type of tables. The data file of InnoDB table can be stored in more than one file so the size of table depends on the disk space.

BDB: BDB is similar to InnoDB in transaction safe. It carries page level locking but data file are not portable.

MERGE: Merge table type is contributed to cover multiple MyISAM tables as a single table so it remove the size limitation from MyISAM tables.

HEAP: Heap table is stored in memory so it is the fastest one. Heap tables do not back up columns with AUTO_INCREMENT, BLOB and TEXT characteristics.

MySQL Download & Installation

Here is the different versions of MySQL, one you can download: http://dev.mysql.com/downloads/.

MySQL Installing on Windows:

This is very much easy to install MySQL on any version of windows:

* Simply download the installer package
* Unzip it anywhere
* Run setup.exe

ByDefault installer setup.exe will install everything under C:\mysql. If you are using windows NT then you will have to use mysqld-nt.exe instead of mysqld.exe. If all became well, you will see some messages about startup and InnoDB. If not, you may have a permissions issue. Make sure that the directory that holds your data is accessible to whatever user the database processes run under. When you install MySQL successfully, then you can see that MySQL not appear in start menu. Hence, if you tend to start the server by double clicking the mysqld executable, you should remember to halt the process by hand by using mysqladmin, Task List, Task Manager, or other Windows-specific means.

Installing MySQL on Linux/Unix

On the Linux/Unix operating system, you can install MySQL via RPM. MySQL AB makes the RPM, which is available for download on its web site is as follows:

* MySQL: This is the MySQL database server, that is manages databases and tables, processes SQL queries and controls user access.
* MySQL-devel: This is the Libraries and header files that come in ready to hand when compiling other programs that use MySQL.
* MySQL-bench: This is the Benchmark and performance testing tools for the MySQL database server.
* MySQL-client: This is the MySQL client programs, which connect and interact with the server.
* MySQL-shared: This is the Shared libraries for the MySQL client.

Now follow the following steps to proceed the installation:

1. Using root user login to the system.
2. Switch to the directory holding the RPM.
3. By executing the following command Install the MySQL database server.

[root@host]# rpm -i MySQL-5.0.9-0.i386.rpm

The Above command installing MySQL server, creating a user of MySQL, creating necessary configuration and starting MySQL server automatically. Which you can find all the MySQL related binaries in /usr/bin and /usr/sbin. All the tables and databases will be created in /var/lib/mysql directory.

4. This step is optional but it is used to install the remaining RPM in the same manner.
[root@host]# rpm -i MySQL-client-5.0.9-0.i386.rpm

[root@host]# rpm -i MySQL-devel-5.0.9-0.i386.rpm

[root@host]# rpm -i MySQL-shared-5.0.9-0.i386.rpm

[root@host]# rpm -i MySQL-bench-5.0.9-0.i386.rpm

Verifying Installation:

After MySQL has been installed, the server has been started and the base tables have been initialized successfully, you can verify whether all is working or not by some simple tests.

To check out server version, use mysqladmin binary. This would be available in /usr/bin on linux and in C:\mysql\bin on windows.
[root@host]# mysqladmin --version

It can show the following output on Linux.
mysqladmin Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386

If you do not find such message then there is some problem in your installation and you would need some help to fix it.

By using MySQL client, you can connect to your MySQL server using following mysql command.
[root@host]# mysql

Now you are connected to the MySQL server and you can execute all the SQL command at mysql> prompt as follows.
mysql> SHOW DATABASES;
+---------------+
| Database |
+---------------+
| mysql |
| test |
+---------------+
2 rows in set (0.13 sec)

After-installation Steps:

You need to set a root password as follows:
[root@host]# mysqladmin -u root password "new_password";

Now to make a connection to your MySQL server, use the following command:
[root@host]# mysql -u root -p

Enter password:*******

Unix users, put your MySQL directory in your PATH, For bash shell, it would be something as:
export PATH=$PATH:/usr/bin:/usr/sbin

If you want to run MySQL server at boot time then make certain you have following entry in /etc/rc.local file
/etc/init.d/mysqld start

Introduction to MySQL

MySQL is a database, it is a data storage area where small sections called TABLES. These tables having number of rows and columns. A database is a data storage feature where user can perform many action like: insert, update, delete, select, sort, arrange, and display information.

MySQL is a open source RDBMS (Relational Database Management System). It is very popular relational database Management System because it is free available for all platform. It is very much reliable and flexible. It provides a very high performance and it is multi threaded and multi user Relational Database management system.

The MySQL support almost all operating system like: Unix , window, and Mac. MySQL is used for the internet applications because it has high speed and highly secure. MySQL was developed to manage large volumes of data at very high speed for the web application.

Features of MySQL

* MySQL Handles large databases.
* MySQL has no memory leaks.
* The MySQL Passwords are secure since all password traffic when connecting to a server is encrypted.
* MySQL is very fast and more reliable for any type of application.
* It is very Lightweight application.
* MySQL command line tool is very powerful and can be used to run SQL queries against database.
* MySQL Supports indexing and binary objects.
* It is allow changes to structure of table while server is running.
* MySQL has a wide user base.
* It is a very fast thread-based memory allocation system.
*

MySQL Written in C and C++ language.
*

MySQL code is tested with different compilers.
*

MySQL is available as a separate program for use in a client/server network environment.
*

The MySQL available for the most Unix operating platform.
* MySQL are the available for window operating system window NT, window 95 ,and window 98.
* MySQL available for OS/2.
* Programming libraries for C, Python, PHP, Java , Delphi etc. are available to connect to MySQL database.

Advantages of MySQL

* Reliability and Performance
* Availability of Source
* Cross-Platform support
* Powerful Uncomplicated software

Features of MySQL 5

* Views: Views is created using columns from one or more tables. It is a virtual table which acts as a table but it contains no data. .
* Stored Procedures and Functions: In this feature it allows to user to plant business logic at database level.
* Triggers: The Triggers is used to create business logic whenever data is inserted, Deleted or updated in the table.

For more about MySQL: http://www.mysql.com/