Upload
som-krishna
View
212
Download
0
Embed Size (px)
DESCRIPTION
my sql
Citation preview
MYSQL
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.
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.
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.
HISTORYLaunched in the year 1996.
Created by Michael Widenius and David Axmark
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
Download MYSQLWe can download at mysql official website, mysql.com
It also comes pre installed in WAMP
Using MYSQLTo work with MySQL we have 2 ways:Using the command prompt window
ORUsing a GUI tool that comes with WAMP called
“phpMyAdmin”
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
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();
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.
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.
Syntax: GRANT ALL ON <database_name>.* TO ‘<username>’;
Eg: GRANT ALL ON books.* TO ‘student’;
Creating DatabaseCREATE DATABASE <database_name>;
CREATE DATABASE Student;
Above command will create a database name “Student”.
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.
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
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