Friday, March 30, 2012

Creating & Managing Databases in MySql

DATABASE:

A database is a collection of tables. It stores various tables and used for managing these tables.

DATABASE COMMANDS

1. CREATE DATABASE: used for creating new database.

Syntax: CREATE DATABASE database_name;
Example: CREATE DATABASE dbase;

Note:- After creating the database you have to set your database as current database, so all work done by you will affect the current database.

We can set a database as current database by using use command.

2. USE DATABASE: To set the database as current database.

Syntax: USE database_name;

Example: USE dbase;
Note:- now all your work will be stored in dbase database

3. Delete database:- The DROP DATABASE command is used to delete a database.

Syntax:
DROP DATABASE database_name;
Example: DROP DATABASE dbase;

***********************************************************************************************

To view all databases type the following command after entering password in the mysql command prompt:-

SHOW DATABASES;

Using MySql First Time

Starting MySql First Time

To start MySql go to Start->All Programs->MySql->MySql Server 5.xx->MySql Command line Client 5.xx

You will see a command prompt asking for the password.Enter root as password & press Enter Key.
Next you will be greeted with details of Mysql you have installed with the mysql prompt.
Now you are ready to use your MySql Server. You can create database & tables & all database related work

Note:- Every time you start your MySql, you have to follow the above procedure.

Closing MySql:-
We can Close MySql in three ways:-

1. By Typing exit in MySql command prompt.
2. By typing q in MySql command prompt.
3. Clicking on the cross button (x) on the right corner of MySql command window.

Now you know how to start & close your MySql. It's time to do some work on your MySql.

Things you should know before start working on MySql.


STEPS TO EXECUTE YOUR MYSQL COMMANDS:-

1. Type your MYSQL command on MYSQL command prompt.
2. End the command with semicolon ;
3. Press ENTER to execute your command & see the magic of MYSQL.

Note:-MYSQL is case-sensitive.

Examples:

1. To print the current Date & Time.
Type following in MySql command prompt.

SELECT NOW();

2. To view current user details Type

SELECT USER( );

3. To view version details of your MySql Type:-

SELECT VERSION();

Note:- we can execute more than one command at a time by saperating them with comma (,).

example:-

To view current user & version details type :-

SELECT USER(), VERSION();

************************************************************************************************
To view result in vertical format type \G in end.

Example:

SELECT USER(), VERSION() \G;

Thursday, March 29, 2012

Installing & Configuring MySql for Windows

To install & configure MySql for Windows follow the step-by-step process below:-

1. Download MySql for windows:-

MySql is available in two Editions

1. Enterprise edition. (Paid version)
2. Community edition. (Free version)

To download the latest version of MySql go to www.mysql.com/downloads/installer
Click on the Download button to download .msi file.

2. Configure MySql for Windows.

After downloading MySql the next step is to Install the MySql on your system.

1. Unzip the mysql-5.5.xx-win32.zip file you just downloaded.

2. Double click on the mysql-5.5.xx-win32.msi file to start installation of MySql.

3. Read the welcome prompt & click Next.

4. Choose between a Typical, Complete, or Custom installation. The Typical
installation provides everything you need to effectively run MySQL, while the
Complete installation installs all the optional components in addition to the
documentation. The Custom installation allows you to wield total control over
what’s installed, in addition to allowing you to choose the installation
directory. Go ahead and choose the Custom installation and click Next.

5. At the top of the Custom Setup screen you’ll be able to determine which
features are installed. I suggest leaving this untouched; however, at the bottom
of the screen you’ll be able to change MySQL’s installation location. The
default is C:\Program Files\MySQL\MySQL Server 5.1. I suggest changing this
to C:\mysql. Click Next, and then click Install in the next window.

6. The installation process begins. Be patient while the process completes.

7. The next two screens contain advertisements. Feel free to click More… on either
of these screens to learn more about the respective offerings, or click Next to
continue the process.

8. The installation process is now complete. You are prompted to configure
MySQL. There’s no time like the present, so make sure this checkbox is
selected and then click Finish.


Configuring MySql for Windows:

1. You are first prompted to choose between Standard Configuration and
Detailed Configuration. Choosing Standard Configuration creates a general purpose
configuration that you can later adjust as necessary. For the purposes
of learning more about what configuration capabilities are at your immediate
disposal, choose Detailed Configuration and click Next.

2. Next, you’ll be asked to identify whether the MySQL server will be used for
development purposes, as a multiuse machine (web and database, for
instance), or as a dedicated MySQL machine. Your choice determines how
much memory will be consumed by MySQL. Choose the server type that suits
your present needs best and click Next.

3. Next, you’ll be prompted for the database configuration that best suits your
needs. For the purposes of this book, you need to choose Multifunctional
Database. The reason for the other two usage types, Transactional Database
Only and Non-Transactional Database Only, will become more apparent as
you learn more about MySQL in later chapters. Choose Multifunctional
Database, click Next, and then accept the InnoDB Tablespace Settings
presented in the next screen by again clicking Next.

4. Next, you’ll be prompted to configure the number of concurrent connections
estimated for the server. You have three options: Decision Support
(DSS)/OLAP, which is intended for a minimal number of concurrent
connections (fewer than 20), such as a small office setting; Online Transaction
Processing (OLTP), which is intended for high-traffic servers such a web server;
or set your own estimated number of connections. After you make your choice,
click Next.

5. Next, you’ll be prompted to determine whether TCP/IP networking should be
enabled and to confirm the default connection port 3306. The port should be
left as set, and TCP/IP networking should be left enabled if you intend to
connect to this server remotely. If all connections will be made locally, disable
this feature. You’ll also be asked whether to enable MySQL’s Strict Mode,
which will cause MySQL to conform with norms found in many other
enterprise databases. You should leave this enabled. Click Next to continue.

6. Next, you’ll be asked to determine which character set the MySQL server
should use. You have three options: Standard Character Set, which is best
suited for English and other Western European languages; Best Support for
Multilingualism, which uses the UTF-8 character set, capable of managing text in a wide
variety of languages; or manually select the character set of your
choosing. After you make your choice, click Next.

7. Next, you’ll be prompted to determine whether MySQL should be installed as a
Windows service, meaning it can be started automatically at system startup,
and shut down at system shutdown or reboot. If this will be a server, or if you
plan to regularly develop with the machine, consider installing it as a Windows
service and enabling the checkbox for starting MySQL automatically.
Additionally, you can add MySQL’s bin directory to the Windows path,
meaning you’ll be able to access any of MySQL’s utilities from the command
line without having to be in the bin directory. These tools are discussed in
further detail in Chapter 28. Enabling both of these options is recommended.
Once you’re done, click Next.

8. In the final configuration window, you’ll be prompted to choose and confirm a
root password. Take care to choose a secure password, but make sure it isn’t
something you’ll forget! You can also choose to enable root access from
remote machines, a feature that is not recommended if you don’t plan to allow
remote connections to this database. You can also choose to create an
anonymous account, something that isn’t recommended under any
circumstances. Click Next, and in the next window, start the configuration
process by clicking Execute. Once the process is complete, click Finish.

Now you are ready to use user MySql RDBMS. Read next post to Learn for How to use MySql.

Introduction to MySql

MySql:
MySql (my sequel) is an open source relational database management system.
This is the most commonly used RDBMS in web applications. MySql is developed by Mysql AB,
later MySql was bought by Sun Microsystems. Now MySql is under Oracle organization.

MySql was developed by MySql Ab group in 1995. The initial release was on 23 May 1995. My
Sql was written in C,C++. MySql is a Cross-Platform means it can work on mostly all
operating Systems.


Features of MySql:- Mysql is worldwide popular because of it's vast features, listed as follows
1. Free to Use:-
One of the most important features is that MySql is free software. Anyone
can use it for free without paying even a single rupee to any organization.

2. Open Source Software:-
The second other feature of MySql is that it is an open source software, means it can be customized by anyone according to their needs. MySql is licensed under GNU(General Public License).

3. Supports Cross-Platform:-
This is also one of the most important feature of MySql for it's popularity. It supports mostly all platforms in the world.MySql can be used with Windows, Linux, Unix, MacOS & other platforms.

4. Fast & Easy:-
In today's world no one likes slow & complex technologies. MySql is so fast & easy that it can be easily used by even novice programmers for their web applications. MySql is fast enough to satisfy anyone for their web application.That's why MySql is so popular.

5. Simple Syntax & Commands:-
MySql uses similar commands like SQL & MS. SQL Server, So anyone having knowledge of any can easily use MySql.

6. Free Additional Utilities:-
Because MySql is free & Open source software so you can find additional utilities suitable to your needs for free on internet. These utilities are developed by software programmer & are free.

These are the most common features that make MYSQL so popular.