SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
MYSQL USER MANAGEMENT
 ROUTINES & TRIGGERS



     D.PRABHU RAJA SINGH
          MySQL DBA
AJENDA
          User Account Management
          User Privileges
          Administrative Privileges
          Database Access Privileges
          Creating and Rename User Account
          Drop User Account
          Grant Privileges
          Revoke Privileges
          Routines and Triggers

2 out of 22
USER MANAGEMENT

 To manage MySQL account for clients that connect to MySQL server
  to access databases.
               * The grant tables used to store account information.
               * The SQL statements used for account management.




 3 out of 22
USER ACCOUNT MANAGEMENT

 In mysql the concept of account is combined with two things: a
  user name and a host name.
 When you connect to the server, it checks only the user name that
  you specify, but also from what host you are connecting.
 Format: ‘user_name’@ ‘host_name’
          Ex: ‘rose’@‘localhost’
 Account        management        statements   such   as   CREATE
 USER,GRANT,REVOKE OR SET PASSWORD.



4 out of 22
USER PRIVILEGES

 It mean a special advantages is given to an user account like
  select,insert,update,delete etc at different levels.
 Two types of privileges, one is administrative privileges and
  other is database privileges.
 Administrative privileges access the account in mysql.
 Database privilege control to access the data stored in
  databases.



5 out of 22
ADMINISTRATIVE PRIVILEGES




6 out of 22
DATABASE ACCESS PRIVILEGES




7 out of 22
CREATING & RENAME USER ACCOUNT

 CREATE USER creates a new account and optionally assign it a
  password.
 It does not grant any privileges.
 Syntax:
   CREATE USER ‘USER_NAME’ @ ‘HOST_NAME’ IDENTIFIED BY
  ‘PASSWORD’;
  -Ex: create user ‘rose’@ ‘localhost’ identified by ‘stem123’;




8 out of 22
CREATING & RENAME USER ACCOUNT

 The above statement creates an account for rose@localhost and
  assign the account a password of “stem123”.
 Alternatively we can give GRANT to create the account and grant it
  privileges at the same time.
 -Ex: Grant all on *.* to ‘rose’@ ‘localhost’ identified by ‘stem123’;
 To rename the user account use this statement as RENAME USER.




9 out of 22
CREATING & RENAME USER ACCOUNT
 Syntax:
                RENAME USER ‘old_user_name’@ ‘old_host_name’ To
               ‘new_user_name’@ ‘old_host_name’;
         Ex: Rename user ‘rose’@ ‘localhost’ to ‘flower’@ ‘localhost’;
 To check the created user in MySQL by using Select command.
 Syntax:
               SELECT USER,HOST FROM MYSQL.USER;
 It will show the list of user with hostname in the user account.




10 out of 22
CREATING & RENAME USER ACCOUNT

 How to set password for a user and change the password for a user.
 Syntax:
      SET PASSWORD for [‘USER_NAME’@ ‘HOST_NAME’]=PASSWORD(‘12345’);

 After change the password to get update in that user account we
  need to do flush privileges to get update.
 Syntax:
               FLUSH PRIVILEGES;




11 out of 22
DROP USER ACCOUNT

 It deletes all records for the account from any grant table in which
  they exist.
 It revokes all privileges for an existing account and then removes
  the account.
 To revoke the privileges without removing the account itself, use
  the revoke statement.
 Syntax:
               DROP USER ‘user_name’@ ‘host_name’;

               Ex: drop user ‘flower’@ ‘localhost’;

12 out of 22
GRANT PRIVILEGES

  It is use to give the authority for the mysql user accounts
   databases.
  To see grant privileges in an account.
  Syntax: SHOW GRANTS;
  Grant privileges can exists in different levels.




13 out of 22
GRANT PRIVILEGES

1)Global levels:
        Any privileges can be granted globally. Global privileges are
  quite powerful and are normally granted only administrative
  accounts. Applied to all databases on a given server.
  Syntax: GRANT ALL ON *.* to ‘user’@‘host_name’
         Ex: grant all on *.* to ‘rose’@‘localhost’;
    In this we can do insert, delete,update,etc in global level
  statement.



14 out of 22
GRANT PRIVILEGES

2)Database level:
               Some   privileges   are   granted   for   specific   databases:
  ALTER,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,
  DELETE, DROP, GRANT, OPTION,INDEX,INSERT,LOCK TABLES,
  SELECT,SHOW VIEW AND UPDATE. A database level privileges
  applies for all tables and stores routines in the databases.
  Syntax: GRANT ALL ON DATABASE_NAME .* to ‘USER’@
  ‘HOST_NAME’;

          Ex: grant all on redrose.* to ‘rose’@‘localhost’;


15 out of 22
GRANT PRIVILEGES

3)Table level:
               Some   privileges    granted     for     specific   tables:
  ALTER,CREATE,DELETE,DROP,GRANT,OPTION,INDEX,INSERT,SELEC
  T AND UPDATE. A table-level privilege applies to specific table in a
  database.
  Syntax: GRANT ALL ON DB_NAME.TABLE_NAME to ‘USER’@‘HOST_NAME’;
          Ex: grant all on redrose.price to ‘rose’@‘localhost’;




16 out of 22
GRANT PRIVILEGES

4)Column level:
       Some privileges granted for specific table columns:
  INSERT,SELECT AND UPDATE.

  Syntax: GRANT ALL ON DB_NAME.TBLE_NAME.COLUMN_NAME TO
  ‘USER’@‘HOST_NAME’;

         Ex: grant all on redrose.price.low to ‘rose’@ ‘localhost’;
5)Routine level:
               Some privileges can be granted for specific stored routines:
  EXECUTE,ALTER,ROUTINE AND GRANT OPTION.


17 out of 22
REVOKE PRIVILEGES

 It enables system administrators to revoke privileges from MySQL
  accounts(Break the rules and regulations that given by GRANT to the
  user account).
  Syntax: REVOKE privilege_type [(column_list)] ,[priv_type
  [(column_list)]]...ON [object_type] privilege_level FROM user [‘user’]
        Ex: revoke all privileges, grant option from‘rose’@‘localhost’;




18 out of 22
ROUTINES AND TRIGGERS

 Routines (otherwise known as stored procedures and stored
  functions).
 When used in conjunction with each other MySQL stored procedures
  and triggers will provide a database that all but runs itself.
 A MySQL stored procedure is a block of code stored on the server
  will normally carry out a series of SQL statements.




19 out of 22
ROUTINES AND TRIGGERS

 This is particularly useful because:
 client applications need to know nothing about the structure or the
  content of a database - they just need to know how to run any
  MySQL stored procedures
 any changes in procedures can be made via the stored procedures -
  those changes will automatically be used by client applications
  without the need to modify the applications
 A stored procedure can only be run by some one or something and
  that's where the MySQL trigger is used.


20 out of 22
ROUTINES AND TRIGGERS

 A MySQL trigger is a piece of code that fires whenever something
  happens to a table, and that something can be one of three table
  events.
               Delete - the trigger fires if something is deleted from table.
               Insert - the trigger fires if something is inserted into the table.
               Update - the trigger fires if the table is updated.
 There is a further refinement as well - the trigger may be fired:
               Before the event occurs.
               After the event occurs.

21 out of 22
THANK YOU




22 out of 22

Contenu connexe

Tendances

Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
wmassie
 

Tendances (20)

pl/sql Procedure
pl/sql Procedurepl/sql Procedure
pl/sql Procedure
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Requirement analysis and specification
Requirement analysis and specificationRequirement analysis and specification
Requirement analysis and specification
 
Relational model
Relational modelRelational model
Relational model
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologies
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
 
Oracle DBA
Oracle DBAOracle DBA
Oracle DBA
 
Joint Application Development
Joint Application DevelopmentJoint Application Development
Joint Application Development
 
Object Relational Database Management System(ORDBMS)
Object Relational Database Management System(ORDBMS)Object Relational Database Management System(ORDBMS)
Object Relational Database Management System(ORDBMS)
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Jsp lifecycle
Jsp   lifecycleJsp   lifecycle
Jsp lifecycle
 
SQL commands
SQL commandsSQL commands
SQL commands
 
MySQL
MySQLMySQL
MySQL
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Data models
Data modelsData models
Data models
 

En vedette (6)

Southeast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksSoutheast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
 
Percona Live 2012PPT:mysql-security-privileges-and-user-management
Percona Live 2012PPT:mysql-security-privileges-and-user-managementPercona Live 2012PPT:mysql-security-privileges-and-user-management
Percona Live 2012PPT:mysql-security-privileges-and-user-management
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replication
 
MYSQL
MYSQLMYSQL
MYSQL
 
Linkedin 101 ppt
Linkedin 101 pptLinkedin 101 ppt
Linkedin 101 ppt
 

Similaire à MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.

mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
pradnyamulay
 

Similaire à MySQL USER MANAGEMENT,ROUTINES & TRIGGERS. (20)

Mysqlsecurityoptionsjan2021
Mysqlsecurityoptionsjan2021Mysqlsecurityoptionsjan2021
Mysqlsecurityoptionsjan2021
 
Mysqldbatrainingsession12privilegesinmysql 170302152348
Mysqldbatrainingsession12privilegesinmysql 170302152348Mysqldbatrainingsession12privilegesinmysql 170302152348
Mysqldbatrainingsession12privilegesinmysql 170302152348
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 
03_DP_300T00A_Secure_Environment.pptx
03_DP_300T00A_Secure_Environment.pptx03_DP_300T00A_Secure_Environment.pptx
03_DP_300T00A_Secure_Environment.pptx
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
2. Introduction-to-MSSQL-Server.pptx
2. Introduction-to-MSSQL-Server.pptx2. Introduction-to-MSSQL-Server.pptx
2. Introduction-to-MSSQL-Server.pptx
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
 
common_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLcommon_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQL
 
Mysql
MysqlMysql
Mysql
 
Trigger in DBMS
Trigger in DBMSTrigger in DBMS
Trigger in DBMS
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
Les14
Les14Les14
Les14
 
My sql basic
My sql basicMy sql basic
My sql basic
 
Les13
Les13Les13
Les13
 
Less07 Users
Less07 UsersLess07 Users
Less07 Users
 
SQL Server Admin Best Practices with DMV's
SQL Server Admin Best Practices with DMV'sSQL Server Admin Best Practices with DMV's
SQL Server Admin Best Practices with DMV's
 
ProxySQL and the Tricks Up Its Sleeve - Percona Live 2022.pdf
ProxySQL and the Tricks Up Its Sleeve - Percona Live 2022.pdfProxySQL and the Tricks Up Its Sleeve - Percona Live 2022.pdf
ProxySQL and the Tricks Up Its Sleeve - Percona Live 2022.pdf
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.

  • 1. MYSQL USER MANAGEMENT ROUTINES & TRIGGERS D.PRABHU RAJA SINGH MySQL DBA
  • 2. AJENDA  User Account Management  User Privileges  Administrative Privileges  Database Access Privileges  Creating and Rename User Account  Drop User Account  Grant Privileges  Revoke Privileges  Routines and Triggers 2 out of 22
  • 3. USER MANAGEMENT  To manage MySQL account for clients that connect to MySQL server to access databases. * The grant tables used to store account information. * The SQL statements used for account management. 3 out of 22
  • 4. USER ACCOUNT MANAGEMENT  In mysql the concept of account is combined with two things: a user name and a host name.  When you connect to the server, it checks only the user name that you specify, but also from what host you are connecting.  Format: ‘user_name’@ ‘host_name’ Ex: ‘rose’@‘localhost’  Account management statements such as CREATE USER,GRANT,REVOKE OR SET PASSWORD. 4 out of 22
  • 5. USER PRIVILEGES  It mean a special advantages is given to an user account like select,insert,update,delete etc at different levels.  Two types of privileges, one is administrative privileges and other is database privileges.  Administrative privileges access the account in mysql.  Database privilege control to access the data stored in databases. 5 out of 22
  • 8. CREATING & RENAME USER ACCOUNT  CREATE USER creates a new account and optionally assign it a password.  It does not grant any privileges.  Syntax: CREATE USER ‘USER_NAME’ @ ‘HOST_NAME’ IDENTIFIED BY ‘PASSWORD’; -Ex: create user ‘rose’@ ‘localhost’ identified by ‘stem123’; 8 out of 22
  • 9. CREATING & RENAME USER ACCOUNT  The above statement creates an account for rose@localhost and assign the account a password of “stem123”.  Alternatively we can give GRANT to create the account and grant it privileges at the same time. -Ex: Grant all on *.* to ‘rose’@ ‘localhost’ identified by ‘stem123’;  To rename the user account use this statement as RENAME USER. 9 out of 22
  • 10. CREATING & RENAME USER ACCOUNT  Syntax: RENAME USER ‘old_user_name’@ ‘old_host_name’ To ‘new_user_name’@ ‘old_host_name’; Ex: Rename user ‘rose’@ ‘localhost’ to ‘flower’@ ‘localhost’;  To check the created user in MySQL by using Select command.  Syntax: SELECT USER,HOST FROM MYSQL.USER;  It will show the list of user with hostname in the user account. 10 out of 22
  • 11. CREATING & RENAME USER ACCOUNT  How to set password for a user and change the password for a user.  Syntax: SET PASSWORD for [‘USER_NAME’@ ‘HOST_NAME’]=PASSWORD(‘12345’);  After change the password to get update in that user account we need to do flush privileges to get update.  Syntax: FLUSH PRIVILEGES; 11 out of 22
  • 12. DROP USER ACCOUNT  It deletes all records for the account from any grant table in which they exist.  It revokes all privileges for an existing account and then removes the account.  To revoke the privileges without removing the account itself, use the revoke statement.  Syntax: DROP USER ‘user_name’@ ‘host_name’; Ex: drop user ‘flower’@ ‘localhost’; 12 out of 22
  • 13. GRANT PRIVILEGES  It is use to give the authority for the mysql user accounts databases.  To see grant privileges in an account.  Syntax: SHOW GRANTS;  Grant privileges can exists in different levels. 13 out of 22
  • 14. GRANT PRIVILEGES 1)Global levels: Any privileges can be granted globally. Global privileges are quite powerful and are normally granted only administrative accounts. Applied to all databases on a given server. Syntax: GRANT ALL ON *.* to ‘user’@‘host_name’ Ex: grant all on *.* to ‘rose’@‘localhost’; In this we can do insert, delete,update,etc in global level statement. 14 out of 22
  • 15. GRANT PRIVILEGES 2)Database level: Some privileges are granted for specific databases: ALTER,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW, DELETE, DROP, GRANT, OPTION,INDEX,INSERT,LOCK TABLES, SELECT,SHOW VIEW AND UPDATE. A database level privileges applies for all tables and stores routines in the databases. Syntax: GRANT ALL ON DATABASE_NAME .* to ‘USER’@ ‘HOST_NAME’; Ex: grant all on redrose.* to ‘rose’@‘localhost’; 15 out of 22
  • 16. GRANT PRIVILEGES 3)Table level: Some privileges granted for specific tables: ALTER,CREATE,DELETE,DROP,GRANT,OPTION,INDEX,INSERT,SELEC T AND UPDATE. A table-level privilege applies to specific table in a database. Syntax: GRANT ALL ON DB_NAME.TABLE_NAME to ‘USER’@‘HOST_NAME’; Ex: grant all on redrose.price to ‘rose’@‘localhost’; 16 out of 22
  • 17. GRANT PRIVILEGES 4)Column level: Some privileges granted for specific table columns: INSERT,SELECT AND UPDATE. Syntax: GRANT ALL ON DB_NAME.TBLE_NAME.COLUMN_NAME TO ‘USER’@‘HOST_NAME’; Ex: grant all on redrose.price.low to ‘rose’@ ‘localhost’; 5)Routine level: Some privileges can be granted for specific stored routines: EXECUTE,ALTER,ROUTINE AND GRANT OPTION. 17 out of 22
  • 18. REVOKE PRIVILEGES  It enables system administrators to revoke privileges from MySQL accounts(Break the rules and regulations that given by GRANT to the user account). Syntax: REVOKE privilege_type [(column_list)] ,[priv_type [(column_list)]]...ON [object_type] privilege_level FROM user [‘user’] Ex: revoke all privileges, grant option from‘rose’@‘localhost’; 18 out of 22
  • 19. ROUTINES AND TRIGGERS  Routines (otherwise known as stored procedures and stored functions).  When used in conjunction with each other MySQL stored procedures and triggers will provide a database that all but runs itself.  A MySQL stored procedure is a block of code stored on the server will normally carry out a series of SQL statements. 19 out of 22
  • 20. ROUTINES AND TRIGGERS  This is particularly useful because:  client applications need to know nothing about the structure or the content of a database - they just need to know how to run any MySQL stored procedures  any changes in procedures can be made via the stored procedures - those changes will automatically be used by client applications without the need to modify the applications  A stored procedure can only be run by some one or something and that's where the MySQL trigger is used. 20 out of 22
  • 21. ROUTINES AND TRIGGERS  A MySQL trigger is a piece of code that fires whenever something happens to a table, and that something can be one of three table events. Delete - the trigger fires if something is deleted from table. Insert - the trigger fires if something is inserted into the table. Update - the trigger fires if the table is updated.  There is a further refinement as well - the trigger may be fired: Before the event occurs. After the event occurs. 21 out of 22