SlideShare a Scribd company logo
Operation of MySQL
by Hideo
1. About MySQL
•MySQL is relational database management
system (RDBMS).
•MySQL is Open Source (Free License).
•A database is a collection of data organized
for the purpose of "sharing and using
multiple" and "searching and processing"
2
2. Create Database (by root user)
$ mysql -u root -p
Enter password: # input password
mysql> create database college; # create DB
mysql> show databases;
3
Database
information_schema
college
mysql
performance_schema
sys
wordpress
3. Create User (by root user)
# Create a test user and give all privileges to the corresponding DB
mysql> grant all on college.* to test@localhost identified by 'test';
mysql> select user from mysql.user; # Confirm that test user was added
mysql> exit
4
user
debian-sys-maint
mysql.session
mysql.sys
root
test
wordpress
4. Login by working user
$ mysql -u test -p
Enter password: # input passwrd
mysql> show databases; # Confirm DB available for working users
mysql> use college; # Set the DB to use
5
Database
information_schema
college
5a. Create Table
mysql> create table tbl_name
(col_name1 data_type1,
col_name2 data_type2, ...);
6
5b. Create Table
mysql> create table staff_register(
id int(4) auto_increment primary key,
department varchar(32) not null,
section varchar(32) not null,
name varchar(32) not null,
phone int(8),
email varchar(32)
);
7
6. Show Table
# Confirm to create table
mysql> show tables;
8
Tables in college
staff_register
7. Description Table
mysql> desc staff_register; # Show column
9
Field Type Null Key Default Extra
id int(4) NO PRI NULL auto_increment
department varchar(32) NO NULL
section varchar(32) NO NULL
name varchar(32) NO NULL
phone int(8) YES NULL
email varchar(32) YES NULL
8. Add Record
mysql> insert into staff_register (id, department, section,
name, phone, email) values (1, 'Technology', 'Applied Science',
'John Brawn', 74111111, 'aaa@gmail.com');
# The description of the column can be omitted only when
specifying values for all columns
mysql> insert into staff_register values (1, 'Technology',
'Applied Science', 'John Brawn', 74111111, 'aaa@gmail.com');
10
9. Update Record
mysql> select * from staff_register; # Comfirm add record
# Changed John Brawn's name to Jack Brawn
mysql> update staff_register set name = 'Jack Brawn' where name =
'John Brawn';
mysql> select * from staff_register; # Comfirm updated record
11
id department section name phone email
1 Technology Applied Science John Brawn 74111111 aaa@gmail.com
id department section name phone email
1 Technology Applied Science Jack Brawn 74111111 aaa@gmail.com
10. Add some record
mysql> insert into staff_register (department, section, name, phone, email)
values ('Technology', 'ICT', 'Jacob', 74111112, 'bbb@gmail.com');
mysql> insert into staff_register (department, section, name, phone) values
('Technology', 'ICT Support', 'Jackson', 74111113);
mysql> insert into staff_register (department, section, name, email) values
('Administration', 'Administration', 'Noah', 'ddd@gmail.com');
mysql> insert into staff_register (department, section, name) values
('Administration', 'Finance', 'Lucas');
mysql> insert into staff_register (department, section, name) values
('Administration', 'Learning Resouces Centre', 'Sophia');
mysql> insert into staff_register (department, section, name, email) values
('Administration', 'Maintenance', 'Chloe', 'fff@yahoo.com');
mysql> insert into staff_register (department, section, name, email) values
('Administration', 'Supplies & Contracts', 'George', 'ggg@yahoo.com');
12
11. Comfirm Record
mysql> select * from staff_register;
13
id department section name phone email
1 Technology Applied Science Jack Brawn 74111111 aaa@gmail.com
2 Technology ICT Jacob 74111112 bbb@gmail.com
3 Technology ICT Support Jackson 74111113 NULL
4 Administration Administration Noah NULL ddd@gmail.com
5 Administration Finance Lucas NULL NULL
6 Administration Learning Resouces Centre Sophia NULL NULL
7 Administration Maintenance Chloe NULL fff@yahoo.com
8 Administration Supplies & Contracts George NULL ggg@yahoo.com
12. Exercise
1. add a record containing your name
to staff_register table.
2. Comfirm added record
14
13. Delete Record
mysql> delete from staff_register where section = 'Finance';
mysql> select * from staff_register; # comfirm deleted record
15
id department section name phone email
1 Technology Applied Science Jack Brawn 74111111 aaa@gmail.com
2 Technology ICT Jacob 74111112 bbb@gmail.com
3 Technology ICT Support Jackson 74111113 NULL
4 Administration Administration Noah NULL ddd@gmail.com
6 Administration Learning Resouces Centre Sophia NULL NULL
7 Administration Maintenance Chloe NULL fff@yahoo.com
8 Administration Supplies & Contracts George NULL ggg@yahoo.com
14. Extraction Conditions
# You can specify the extraction condition in the where clause.
mysql> select * from staff_register where department = "Administration";
16
id department section name phone email
4 Administration Administration Noah NULL ddd@gmail.com
6 Administration Learning Resouces Centre Sophia NULL NULL
7 Administration Maintenance Chloe NULL fff@yahoo.com
8 Administration Supplies & Contracts George NULL ggg@yahoo.com
15. LIKE Operator
# You can also use the LIKE operator and the wildcard character "%"
to specify a partial match condition for a string.
mysql> select * from staff_register where email like '%yahoo.com';
17
id department section name phone email
7 Administration Maintenance Chloe NULL fff@yahoo.com
8 Administration Supplies & Contracts George NULL ggg@yahoo.com
16. Delete Table
mysql> truncate table staff_register; # Delete data in staff_register table
mysql> select * from staff_register; # Comfirm deleted record
mysql> drop table staff_register; # Delete staff_register table
mysql> show tables; # Comfirm deleted table
18
17. Delete User (by root user)
$ mysql -u root -p
Enter password: # input password
# deprive access authority to all databases from the test user
mysql> revoke all privileges on *.* from test@localhost;
mysql> drop user test@localhost; # delete test user
mysql> select user from mysql.user; # comfirm deleted test user
mysql> flush privileges; # Reflect test user deletion on MySQL server
mysql> exit
19

More Related Content

PPTX
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracaleDriver
DOCX
Sql full tutorial
PPTX
Database Connectivity in PHP
PDF
Capturing, Analyzing, and Optimizing your SQL
PDF
Introduction to php database connectivity
PDF
lab56_db
PPT
PHP - Getting good with MySQL part II
PDF
Sql Injection Myths and Fallacies
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracaleDriver
Sql full tutorial
Database Connectivity in PHP
Capturing, Analyzing, and Optimizing your SQL
Introduction to php database connectivity
lab56_db
PHP - Getting good with MySQL part II
Sql Injection Myths and Fallacies

What's hot (20)

PPT
Synapse india reviews on php and sql
PDF
4.3 MySQL + PHP
PPT
MYSQL - PHP Database Connectivity
TXT
Salesforce, APEX Concepts
PDF
SQL Injection Tutorial
PPTX
03. sql and other injection module v17
PPTX
Mysql
PDF
SQLite in Adobe AIR
PDF
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
PDF
DBD::SQLite
PDF
PHP with MySQL
PPT
Database presentation
PPT
Php with MYSQL Database
PPTX
Mysql python
PDF
Mysql python
PDF
Powerful Explain in MySQL 5.6
KEY
10x Performance Improvements
PPT
Sql injection
PDF
Mule caching strategy with redis cache
PDF
MySQL for beginners
Synapse india reviews on php and sql
4.3 MySQL + PHP
MYSQL - PHP Database Connectivity
Salesforce, APEX Concepts
SQL Injection Tutorial
03. sql and other injection module v17
Mysql
SQLite in Adobe AIR
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
DBD::SQLite
PHP with MySQL
Database presentation
Php with MYSQL Database
Mysql python
Mysql python
Powerful Explain in MySQL 5.6
10x Performance Improvements
Sql injection
Mule caching strategy with redis cache
MySQL for beginners
Ad

Similar to MySQL (20)

PDF
MySQL Best Practices - OTN
PDF
12c db upgrade from 11.2.0.4
PPT
SQLSecurity.ppt
PPT
SQLSecurity.ppt
PPTX
Locking Down Your MySQL Database.pptx
ODT
Mysql
PDF
MySQL server security
PDF
<x> Rails Web App Security Title
PDF
MySQL Best Practices - OTN LAD Tour
ODP
Msql
PPT
SQLMAP Tool Usage - A Heads Up
PPTX
Database connectivity in python
PPT
MySQL crash course by moshe kaplan
PDF
70433 Dumps DB
PPTX
PYTHON_DATABASE_CONNECTIVITY_for_class_12.pptx
PPTX
Protractor framework – how to make stable e2e tests for Angular applications
PDF
RMySQL Tutorial For Beginners
PPTX
python db connection samples and program
PDF
Brief introduction into SQL injection attack scenarios
MySQL Best Practices - OTN
12c db upgrade from 11.2.0.4
SQLSecurity.ppt
SQLSecurity.ppt
Locking Down Your MySQL Database.pptx
Mysql
MySQL server security
<x> Rails Web App Security Title
MySQL Best Practices - OTN LAD Tour
Msql
SQLMAP Tool Usage - A Heads Up
Database connectivity in python
MySQL crash course by moshe kaplan
70433 Dumps DB
PYTHON_DATABASE_CONNECTIVITY_for_class_12.pptx
Protractor framework – how to make stable e2e tests for Angular applications
RMySQL Tutorial For Beginners
python db connection samples and program
Brief introduction into SQL injection attack scenarios
Ad

More from Hideo Amezawa (10)

PDF
JICA国際協力出前講座ーアフリカの国際的な支援からの自立に向けて
PPTX
Windows server
PPTX
Network
PPTX
Linux basic1&2
PPTX
Linux basic3
PPTX
Ansible
ODP
カミーノ・デ・サンティアゴ
ODP
Japan overseas cooperation volunteers
ODP
青年海外協力隊のブログサイト
ODP
JICA国際協力出前講座ーアフリカの国際的な支援からの自立に向けて
Windows server
Network
Linux basic1&2
Linux basic3
Ansible
カミーノ・デ・サンティアゴ
Japan overseas cooperation volunteers
青年海外協力隊のブログサイト

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Computing-Curriculum for Schools in Ghana
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Trump Administration's workforce development strategy
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Cell Types and Its function , kingdom of life
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
master seminar digital applications in india
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Computing-Curriculum for Schools in Ghana
Module 4: Burden of Disease Tutorial Slides S2 2025
FourierSeries-QuestionsWithAnswers(Part-A).pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial diseases, their pathogenesis and prophylaxis
Final Presentation General Medicine 03-08-2024.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Trump Administration's workforce development strategy
A systematic review of self-coping strategies used by university students to ...
Cell Types and Its function , kingdom of life
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pharma ospi slides which help in ospi learning
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
01-Introduction-to-Information-Management.pdf
Orientation - ARALprogram of Deped to the Parents.pptx
master seminar digital applications in india
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

MySQL

  • 2. 1. About MySQL •MySQL is relational database management system (RDBMS). •MySQL is Open Source (Free License). •A database is a collection of data organized for the purpose of "sharing and using multiple" and "searching and processing" 2
  • 3. 2. Create Database (by root user) $ mysql -u root -p Enter password: # input password mysql> create database college; # create DB mysql> show databases; 3 Database information_schema college mysql performance_schema sys wordpress
  • 4. 3. Create User (by root user) # Create a test user and give all privileges to the corresponding DB mysql> grant all on college.* to test@localhost identified by 'test'; mysql> select user from mysql.user; # Confirm that test user was added mysql> exit 4 user debian-sys-maint mysql.session mysql.sys root test wordpress
  • 5. 4. Login by working user $ mysql -u test -p Enter password: # input passwrd mysql> show databases; # Confirm DB available for working users mysql> use college; # Set the DB to use 5 Database information_schema college
  • 6. 5a. Create Table mysql> create table tbl_name (col_name1 data_type1, col_name2 data_type2, ...); 6
  • 7. 5b. Create Table mysql> create table staff_register( id int(4) auto_increment primary key, department varchar(32) not null, section varchar(32) not null, name varchar(32) not null, phone int(8), email varchar(32) ); 7
  • 8. 6. Show Table # Confirm to create table mysql> show tables; 8 Tables in college staff_register
  • 9. 7. Description Table mysql> desc staff_register; # Show column 9 Field Type Null Key Default Extra id int(4) NO PRI NULL auto_increment department varchar(32) NO NULL section varchar(32) NO NULL name varchar(32) NO NULL phone int(8) YES NULL email varchar(32) YES NULL
  • 10. 8. Add Record mysql> insert into staff_register (id, department, section, name, phone, email) values (1, 'Technology', 'Applied Science', 'John Brawn', 74111111, 'aaa@gmail.com'); # The description of the column can be omitted only when specifying values for all columns mysql> insert into staff_register values (1, 'Technology', 'Applied Science', 'John Brawn', 74111111, 'aaa@gmail.com'); 10
  • 11. 9. Update Record mysql> select * from staff_register; # Comfirm add record # Changed John Brawn's name to Jack Brawn mysql> update staff_register set name = 'Jack Brawn' where name = 'John Brawn'; mysql> select * from staff_register; # Comfirm updated record 11 id department section name phone email 1 Technology Applied Science John Brawn 74111111 aaa@gmail.com id department section name phone email 1 Technology Applied Science Jack Brawn 74111111 aaa@gmail.com
  • 12. 10. Add some record mysql> insert into staff_register (department, section, name, phone, email) values ('Technology', 'ICT', 'Jacob', 74111112, 'bbb@gmail.com'); mysql> insert into staff_register (department, section, name, phone) values ('Technology', 'ICT Support', 'Jackson', 74111113); mysql> insert into staff_register (department, section, name, email) values ('Administration', 'Administration', 'Noah', 'ddd@gmail.com'); mysql> insert into staff_register (department, section, name) values ('Administration', 'Finance', 'Lucas'); mysql> insert into staff_register (department, section, name) values ('Administration', 'Learning Resouces Centre', 'Sophia'); mysql> insert into staff_register (department, section, name, email) values ('Administration', 'Maintenance', 'Chloe', 'fff@yahoo.com'); mysql> insert into staff_register (department, section, name, email) values ('Administration', 'Supplies & Contracts', 'George', 'ggg@yahoo.com'); 12
  • 13. 11. Comfirm Record mysql> select * from staff_register; 13 id department section name phone email 1 Technology Applied Science Jack Brawn 74111111 aaa@gmail.com 2 Technology ICT Jacob 74111112 bbb@gmail.com 3 Technology ICT Support Jackson 74111113 NULL 4 Administration Administration Noah NULL ddd@gmail.com 5 Administration Finance Lucas NULL NULL 6 Administration Learning Resouces Centre Sophia NULL NULL 7 Administration Maintenance Chloe NULL fff@yahoo.com 8 Administration Supplies & Contracts George NULL ggg@yahoo.com
  • 14. 12. Exercise 1. add a record containing your name to staff_register table. 2. Comfirm added record 14
  • 15. 13. Delete Record mysql> delete from staff_register where section = 'Finance'; mysql> select * from staff_register; # comfirm deleted record 15 id department section name phone email 1 Technology Applied Science Jack Brawn 74111111 aaa@gmail.com 2 Technology ICT Jacob 74111112 bbb@gmail.com 3 Technology ICT Support Jackson 74111113 NULL 4 Administration Administration Noah NULL ddd@gmail.com 6 Administration Learning Resouces Centre Sophia NULL NULL 7 Administration Maintenance Chloe NULL fff@yahoo.com 8 Administration Supplies & Contracts George NULL ggg@yahoo.com
  • 16. 14. Extraction Conditions # You can specify the extraction condition in the where clause. mysql> select * from staff_register where department = "Administration"; 16 id department section name phone email 4 Administration Administration Noah NULL ddd@gmail.com 6 Administration Learning Resouces Centre Sophia NULL NULL 7 Administration Maintenance Chloe NULL fff@yahoo.com 8 Administration Supplies & Contracts George NULL ggg@yahoo.com
  • 17. 15. LIKE Operator # You can also use the LIKE operator and the wildcard character "%" to specify a partial match condition for a string. mysql> select * from staff_register where email like '%yahoo.com'; 17 id department section name phone email 7 Administration Maintenance Chloe NULL fff@yahoo.com 8 Administration Supplies & Contracts George NULL ggg@yahoo.com
  • 18. 16. Delete Table mysql> truncate table staff_register; # Delete data in staff_register table mysql> select * from staff_register; # Comfirm deleted record mysql> drop table staff_register; # Delete staff_register table mysql> show tables; # Comfirm deleted table 18
  • 19. 17. Delete User (by root user) $ mysql -u root -p Enter password: # input password # deprive access authority to all databases from the test user mysql> revoke all privileges on *.* from test@localhost; mysql> drop user test@localhost; # delete test user mysql> select user from mysql.user; # comfirm deleted test user mysql> flush privileges; # Reflect test user deletion on MySQL server mysql> exit 19

Editor's Notes

  • #2: タイトル : 60px content : 40px
  • #3: タイトル : 60px content : 40px
  • #8: int: Integer type varchar: Variable length character string
  • #15: mysql> insert into staff_register (department, section, name, phone, email) values ('Technology', 'ICT', 'Jacob', 74111112, 'bbb@gmail.com'); mysql> select * from staff_register;
  • #20: deprive : 取り上げる、剥奪する reflect : 反映する