17
MYSQL

MYSQL_1

Embed Size (px)

DESCRIPTION

my sql

Citation preview

Page 1: MYSQL_1

MYSQL

Page 2: MYSQL_1

Database TerminologiesDatabase: In general, a database is a collection of  logically related files or records.

Database Management System: A Database Management System is a program(MySQL,Oracle etc) that can store large amounts of information in an organized format.

Page 3: MYSQL_1

Database Terminologies

Table: Table is a collection of rows and columns. Columns keep only one specific (e.g. First-Name, Last-Name, Age etc. ) data where rows are the collection of columns (e.g. Ajay, Sharma, 37 etc.). Tables store data in a grid like pattern of columns and rows.

Page 4: MYSQL_1

SQLSQL: Structured Query language (SQL) pronounced as “S-Q-L” or sometimes as “See-Quel”is actually the standard language for dealing with Relational Databases. SQL can be effectively used to insert, search, update, delete database records. Relational databases like MySQL, Oracle, Ms SQL server, Sybase, etc use SQL !  SQL syntaxes used in these databases are almost similar, except the fact that some are using few different syntaxes and even proprietary SQL syntaxes.

Page 5: MYSQL_1

HISTORYLaunched in the year 1996.

Created by Michael Widenius and David Axmark

Page 6: MYSQL_1

MySQLMySQL is a very popular, open source database.Officially pronounced “my Ess Que Ell” (not my sequel).Handles very large databases; very fast performance.MySQL is an SQL (Structured Query Language) based

relational database management system (DBMS)MySQL is compatible with standard SQLMySQL is frequently used by PHP

Page 7: MYSQL_1

Download MYSQLWe can download at mysql official website, mysql.com

It also comes pre installed in WAMP

Page 8: MYSQL_1

Using MYSQLTo work with MySQL we have 2 ways:Using the command prompt window

ORUsing a GUI tool that comes with WAMP called

“phpMyAdmin”

Page 9: MYSQL_1

Using Command Prompt

1. Open cmd.2. Change directory to wamp.3. Now go to the following path:<drive>:\wamp\bin\mysql\mysql5.1.53\bin

4. Login to the root user using following command:

mysql –u root -p

Page 10: MYSQL_1

5. It will ask for password, simply strike ENTER

6. You would be now logged in to mysql as “root” user.

7. To verify this , type the command: select user();

Page 11: MYSQL_1

Creating User1. Go to “root” user as described in previous slide.2. Create a new database using the following command:

Create Database Bookdb;

3. This will create a new database called “BookDb”.4. Now we create a new user.

Page 12: MYSQL_1

Syntax: CREATE USER <username>@localhost IDENTIFIED BY ‘<password>;

Eg:

CREATE USER student@localhost IDENTIFIED BY ‘student’;

5. Now grant permission to newly created user using GRANT command.

Page 13: MYSQL_1

Syntax: GRANT ALL ON <database_name>.* TO ‘<username>’;

Eg: GRANT ALL ON books.* TO ‘student’;

Page 14: MYSQL_1

Creating DatabaseCREATE DATABASE <database_name>;

CREATE DATABASE Student;

Above command will create a database name “Student”.

Page 15: MYSQL_1

Displaying DatabaseSHOW DATABASES;

Above command will display all the database present in the MYSQL database server.

Select Database();

Above command will show the current database.

Page 16: MYSQL_1

Selecting a database to workBefore we work on a particular database we have to select a database using –

USE <database_name>;

USE Student;

Now all the queries will take effects on the selected database

Page 17: MYSQL_1

Removing DatabaseTo delete a database -

DROP DATABASE <db_name>;

All the data and related objects inside the database are permanently deleted and this cannot be undone