Key refers to the type of key that may affect the field. Primary (PRI), Unique (UNI) ...
n row in set (0.00 sec)
Where n is the number of fields in the table.
Creating user
First, you need to create a user and then give the user permissions on certain databases/tables.
While creating the user, you also need to specify where this user can connect from.
CREATE USER 'user'@'localhost' IDENTIFIED BY 'some_password';
Will create a user that can only connect on the local machine where the database is hosted.
CREATE USER 'user'@'%' IDENTIFIED BY 'some_password';
Will create a user that can connect from anywhere (except the local machine).
Example return value:
Query OK, 0 rows affected (0.00 sec)
Adding privileges
Grant common, basic privileges to the user for all tables of the specified database:
GRANT SELECT, INSERT, UPDATE ON databaseName.* TO 'userName'@'localhost';
Grant all privileges to the user for all tables on all databases (attention with this):
GRANT ALL ON *.* TO 'userName'@'localhost' WITH GRANT OPTION;
As demonstrated above, *.* targets all databases and tables, databaseName.* targets all tables of
the specific database. It is also possible to specify database and table like so
databaseName.tableName.
WITH GRANT OPTION should be left out if the user need not be able to grant other users privileges.
Privileges can be either
ALL
or a combination of the following, each separated by a comma (non-exhaustive list).
SELECT
INSERT
UPDATE
DELETE
https://riptutorial.com/ 6