SlideShare a Scribd company logo
Adolfo Nasol

MYSQL CHEAT SHEET - PART 1

http://cavhost.com

Short List of MySQL Commands
Other Useful Commands
SELECT user FROM mysql.user
Will get the list of all MySQL user accounts
SELECT DISTINCT user FROM mysql.user
Get the list of all MySQL user accounts removing duplicate user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'
Creating a new user in MySQL database but without privileges or permission to do
anything
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'
Provide global privileges to all databases and tables, note that the asterisk in this
command refer to database and table that the user can access
FLUSH PRIVILEGES
Reload all the privileges
How To Grant Different User Permissions
Here is a short list of other common possible permissions that users can enjoy.
ALL PRIVILEGES - as we saw previously, this would allow a MySQL user all
access to a designated database (or if no database is selected, across the system)
CREATE - allows them to create new tables or databases
DROP - allows them to them to delete tables or databases
DELETE - allows them to delete rows from tables
INSERT - allows them to insert rows into tables
SELECT- allows them to use the Select command to read through databases
UPDATE - allow them to update table rows

1 of 2

http://danreb.com

Cavhost Web Solutions
Adolfo Nasol

MYSQL CHEAT SHEET - PART 1

http://cavhost.com

GRANT OPTION - allows them to grant or remove other users' privileges
To provide a specific user with a permission, you can use this framework:
GRANT [type of permission] ON [database name].[table name] TO โ€˜[username]โ€™@'localhostโ€™;

If you want to give them access to any database or to any table, make sure to put an
asterisk (*) in the place of the database name or table name.
Each time you update or change a permission be sure to use the Flush Privileges
command.
If you need to revoke a permission, the structure is almost identical to granting it:
REVOKE [type of permission] ON [database name].[table name] TO โ€˜[username]โ€™@โ€˜localhostโ€™;

Just as you can delete databases with DROP, you can use DROP to delete a user
altogether:
DROP USER โ€˜demoโ€™@โ€˜localhostโ€™;

To test out your new user, log out by typing
quit

and log back in with this command in terminal:
mysql -u [username]-p

2 of 2

http://danreb.com

Cavhost Web Solutions

More Related Content

PDF
MySql 5.7 Backup Script
PPT
My sql with querys
PPTX
Beginner guide to mysql command line
PPTX
MySql:Introduction
PPTX
Oracle Database DML DDL and TCL
PDF
Kp.3 pengaturan sistem dan user
TXT
Oracle ORA Errors
PPTX
Database administration commands
MySql 5.7 Backup Script
My sql with querys
Beginner guide to mysql command line
MySql:Introduction
Oracle Database DML DDL and TCL
Kp.3 pengaturan sistem dan user
Oracle ORA Errors
Database administration commands

What's hot (20)

ODP
PPT
Mysql ppt
ODP
My sql
PPT
Fatal error my sql duplicate packages
ย 
PPTX
PostgreSQL- An Introduction
PDF
Columnrename9i
PPT
Sequences and indexes
PDF
ACLs
PPTX
PostgreSQL Database Slides
PPT
MySQL
PPTX
Mapping and listing with mule
ย 
PDF
NonStop SQL/MX DBS demo with iTP Webserver
PPTX
Mule properties
PPTX
Introduction databases and MYSQL
ODP
Database Connection With Mysql
PDF
Introduction to php database connectivity
ODT
Mysql
PDF
NonStop SQL/MX DBS Explained
TXT
Db health check
Mysql ppt
My sql
Fatal error my sql duplicate packages
ย 
PostgreSQL- An Introduction
Columnrename9i
Sequences and indexes
ACLs
PostgreSQL Database Slides
MySQL
Mapping and listing with mule
ย 
NonStop SQL/MX DBS demo with iTP Webserver
Mule properties
Introduction databases and MYSQL
Database Connection With Mysql
Introduction to php database connectivity
Mysql
NonStop SQL/MX DBS Explained
Db health check
Ad

Similar to Mysql cheatsheet - Part 2 (20)

PDF
Mysql cheatsheet
PDF
Mysql administration
PDF
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
PPT
My sql presentation
PPT
Mysql grand
PDF
Managing a shared mysql farm dpc11
PDF
Mysql nowwhat
PPTX
My sql administration
PDF
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
PPTX
PHP mysql Introduction database
PPT
MYSQL
PPT
MYSQL
ย 
PPTX
Using Mysql.pptx
PPTX
Introduction To MySQL Lecture 1
PPT
MySQL and its basic commands
PDF
Getting started with my sql
ย 
PDF
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
PDF
Mysqlsecurityoptionsjan2021
Mysql cheatsheet
Mysql administration
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
My sql presentation
Mysql grand
Managing a shared mysql farm dpc11
Mysql nowwhat
My sql administration
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
PHP mysql Introduction database
MYSQL
MYSQL
ย 
Using Mysql.pptx
Introduction To MySQL Lecture 1
MySQL and its basic commands
Getting started with my sql
ย 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
Mysqlsecurityoptionsjan2021
Ad

More from Adolfo Nasol (13)

PDF
Drupal debugging tips
PPTX
Managing drupal views in code
PDF
Event Registration System Part 2
PDF
Events Registration System Part 1
PDF
Installing mandriva linux mandriva community wiki
PPTX
Drush for drupal website builder
PPTX
Converting (X)HTML/CSS template to Drupal 7 Theme
PPTX
Research methods
PPTX
Personality
PDF
Creating Drupal 7 subtheme
DOCX
Chs nc2 reviewer - with oral questioning
PPTX
Operating System Concepts : Reports
PPTX
Drupal Checklist for Site Builder and Web admin
Drupal debugging tips
Managing drupal views in code
Event Registration System Part 2
Events Registration System Part 1
Installing mandriva linux mandriva community wiki
Drush for drupal website builder
Converting (X)HTML/CSS template to Drupal 7 Theme
Research methods
Personality
Creating Drupal 7 subtheme
Chs nc2 reviewer - with oral questioning
Operating System Concepts : Reports
Drupal Checklist for Site Builder and Web admin

Recently uploaded (20)

PPTX
Types of Social Media Marketing for Business Success
PDF
The Fastest Way to Look Popular Buy Reactions Today
PDF
Presence That Pays Off Activate My Social Growth
PDF
Real Presence. Real Power. Boost with Authenticity
PDF
Live Echo Boost on TikTok_ Double Devices, Higher Ranks
ย 
PDF
The Edge Youโ€™ve Been Missing Get the Sociocosmos Edge
PDF
11111111111111111111111111111111111111111111111
PPT
memimpindegra1uejehejehdksnsjsbdkdndgggwksj
PDF
Your Best Post Vanished. Blame the Attention Economy
PDF
StarNetCafeSB2012D3POYNagaworld2-Hotel-Casino-Phnom Entertainment
PDF
Why Digital Marketing Matters in Todayโ€™s World Ask ChatGPT
PPTX
Result-Driven Social Media Marketing Services | Boost ROI
PPTX
Preposition and Asking and Responding Suggestion.pptx
PDF
TikTok Live shadow viewers_ Who watches without being counted
ย 
PPTX
Strategies for Social Media App Enhancement
PPTX
Office Administration Courses in Trivandrum That Employers Value.pptx
PDF
Subscribe This Channel Subscribe Back You
PDF
25K Btc Enabled Cash App Accounts โ€“ Safe, Fast, Verified.pdf
PDF
How can India improve its Public Diplomacy - Social Media.pdf
PPTX
Developing lesson plan gejegkavbw gagsgf
Types of Social Media Marketing for Business Success
The Fastest Way to Look Popular Buy Reactions Today
Presence That Pays Off Activate My Social Growth
Real Presence. Real Power. Boost with Authenticity
Live Echo Boost on TikTok_ Double Devices, Higher Ranks
ย 
The Edge Youโ€™ve Been Missing Get the Sociocosmos Edge
11111111111111111111111111111111111111111111111
memimpindegra1uejehejehdksnsjsbdkdndgggwksj
Your Best Post Vanished. Blame the Attention Economy
StarNetCafeSB2012D3POYNagaworld2-Hotel-Casino-Phnom Entertainment
Why Digital Marketing Matters in Todayโ€™s World Ask ChatGPT
Result-Driven Social Media Marketing Services | Boost ROI
Preposition and Asking and Responding Suggestion.pptx
TikTok Live shadow viewers_ Who watches without being counted
ย 
Strategies for Social Media App Enhancement
Office Administration Courses in Trivandrum That Employers Value.pptx
Subscribe This Channel Subscribe Back You
25K Btc Enabled Cash App Accounts โ€“ Safe, Fast, Verified.pdf
How can India improve its Public Diplomacy - Social Media.pdf
Developing lesson plan gejegkavbw gagsgf

Mysql cheatsheet - Part 2

  • 1. Adolfo Nasol MYSQL CHEAT SHEET - PART 1 http://cavhost.com Short List of MySQL Commands Other Useful Commands SELECT user FROM mysql.user Will get the list of all MySQL user accounts SELECT DISTINCT user FROM mysql.user Get the list of all MySQL user accounts removing duplicate user CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password' Creating a new user in MySQL database but without privileges or permission to do anything GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost' Provide global privileges to all databases and tables, note that the asterisk in this command refer to database and table that the user can access FLUSH PRIVILEGES Reload all the privileges How To Grant Different User Permissions Here is a short list of other common possible permissions that users can enjoy. ALL PRIVILEGES - as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system) CREATE - allows them to create new tables or databases DROP - allows them to them to delete tables or databases DELETE - allows them to delete rows from tables INSERT - allows them to insert rows into tables SELECT- allows them to use the Select command to read through databases UPDATE - allow them to update table rows 1 of 2 http://danreb.com Cavhost Web Solutions
  • 2. Adolfo Nasol MYSQL CHEAT SHEET - PART 1 http://cavhost.com GRANT OPTION - allows them to grant or remove other users' privileges To provide a specific user with a permission, you can use this framework: GRANT [type of permission] ON [database name].[table name] TO โ€˜[username]โ€™@'localhostโ€™; If you want to give them access to any database or to any table, make sure to put an asterisk (*) in the place of the database name or table name. Each time you update or change a permission be sure to use the Flush Privileges command. If you need to revoke a permission, the structure is almost identical to granting it: REVOKE [type of permission] ON [database name].[table name] TO โ€˜[username]โ€™@โ€˜localhostโ€™; Just as you can delete databases with DROP, you can use DROP to delete a user altogether: DROP USER โ€˜demoโ€™@โ€˜localhostโ€™; To test out your new user, log out by typing quit and log back in with this command in terminal: mysql -u [username]-p 2 of 2 http://danreb.com Cavhost Web Solutions