Which of the following commands can be used to create a new user with an assigned password, with access to all tables in a database and with permission to grant other users access to that database on a MySQL server? code example

Example 1: mysql create user

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';
FLUSH PRIVILEGES;

Example 2: mysql create user

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
#grant permissions to a specic database and/or table 
GRANT ALL PRIVILEGES ON database.table TO 'newuser'@'localhost';
#Or grant wildcar permission to any DB/table
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';

Tags:

Sql Example