User MGT and Views
User MGT and Views
User Management
The MySQL user is a record in the USER table of the MySQL server that contains the
login information, account privileges, and the host information for MySQL account.
It is essential to create a user in MySQL for accessing and managing the databases.
The MySQL Create User statement allows us to create a new user account in the
database server.
It also enables us to control the accounts that should be initially locked or unlocked.
MySQL has a feature that provides many control options to the administrators and users on
the database.
GRANT Statement
The grant statement enables system administrators to assign privileges and roles to
the MySQL user accounts so that they can use the assigned permission on the database
whenever required.
Syntax:
GRANT privilege_name(s)
ON object
TO user_account_name;
Object: It determines the privilege level on which the access rights are being granted. It
means granting privilege to the table; then the object should be the name of the table.
User_account_name: It determines the account name of the user to whom the access
rights would be granted.
MySQL supports the following privilege levels:
Syntax
REVOKE privilege_name(s)
ON object
FROM user_account_name
MySQL supports the following privilege levels:
Database REVOKE ALL ON mydb.* It applies to revoke all privileges from objects in the
FROM john@localhost; current database.
The main difference between them is that a table is an object that consists of rows and
columns to store and retrieve data whenever the user needs it.
In contrast, the view is a virtual table based on an SQL statement's result set and will
disappear when the current session is closed.
The view is a virtual/logical table formed as a result of a query and used to view or
manipulate parts of the table.
We can create the columns of the view from one or more tables. Its content is based
on base tables.
The view is a database object with no values and contains rows and columns the same as
real tables. It does not occupy space on our systems.
The following are the main advantages of the view:
3.It simplifies complex queries because it can draw data from multiple tables and
present it as a single table.
4.It helps in data security that shows only authorized information to the users.
5.It presents a consistent, unchanged image of the database structure, even if the source
tables are renamed, split, or restructured.