You are on page 1of 16

MySQL Workbench

User management
MySQL Workbench
• MySQL Workbench is a unified visual database
designing or graphical user interface tool used
for working with database architects, develop-
ers, and Database Administrators. It is devel-
oped and maintained by Oracle.
• It provides SQL development, data modeling,
data migration, and comprehensive administra-
tion tools for server configuration, user adminis-
tration, backup, and many more. We can use
this Server Administration for creating new
physical data models, E-R diagrams, and for
SQL development (run queries, etc.).
MySQL Create User
Syntax for creating user

CREATE USER [IF NOT EXISTS] account_name


IDENTIFIED BY 'password’;

Note: The Create User creates a new user with


full access. So, if you want to give privileges to
the user, it is required to use the GRANT state-
ment.
MySQL Create User

Command to show all users in the current MySQL


server.

select user from mysql.user;


Grant Privileges to the MySQL New User

ALL PRIVILEGES: It permits all privileges to a


new user account.
CREATE: It enables the user account to create
databases and tables.
DROP: It enables the user account to drop data-
bases and tables.
Grant Privileges to the MySQL New User

DELETE: It enables the user account to delete


rows from a specific table.
INSERT: It enables the user account to insert
rows into a specific table.
SELECT: It enables the user account to read a
database.
UPDATE: It enables the user account to update
table rows.
Grant Privileges to the MySQL New User

Syntax

GRANT ALL PRIVILEGES ON * . * TO peter@lo-


calhost;

GRANT CREATE, SELECT, INSERT ON * . * TO


peter@localhost;

SHOW GRANTS for username;  
Grant Privileges to the MySQL New User

Flush all the privileges of a user account for


changes occurs immediately,

FLUSH PRIVILEGES;
MySQL Drop User

Syntax

DROP USER 'account_name’;

DROP USER john@localhost, peter@localhost;  
MySQL Show Users/List All Users

Syntax

Select user from mysql.user;  

If we want to see more information on the user


table, execute the command below:

DESC mysql.user;  
MySQL Show Users/List All Users

Syntax

SELECT user, host, account_locked, password_e
xpired FROM mysql.user;  

We can get information of the current user by us-


ing the user() or current_user() function
Select user();  

Select current_user();  
MySQL Show Users/List All Users

We can see the currently logged user in the data-


base server by using the following query

SELECT user, host, db, command FROM infor-


mation_schema.processlist;
Change MySQL User Password

MySQL allows us to change the user account


password in three different ways, which are given
below:

UPDATE Statement
SET PASSWORD Statement
ALTER USER Statement
Change MySQL User Password

UPDATE mysql.user SET authentication_string =


'root1234' WHERE user = 'user2' AND host = 'lo-
calhost’;

ALTER USER 'user2'@'localhost' IDENTIFIED BY


'admin123’;

SET PASSWORD FOR 'user2'@'localhost' = 'ad-


min123';
MySQL Workbench Environment
Setup
THANK YOU

You might also like