Introduction
Creating users lets you control who can access your database. It helps keep your data safe and organized.
Creating users lets you control who can access your database. It helps keep your data safe and organized.
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
CREATE USER 'alice'@'localhost' IDENTIFIED BY 'mypassword';
CREATE USER 'bob'@'%' IDENTIFIED BY 'secure123';
This creates a user 'john' who can connect from the local machine, then shows what permissions he has (none by default).
CREATE USER 'john'@'localhost' IDENTIFIED BY 'johnspass'; SHOW GRANTS FOR 'john'@'localhost';
After creating a user, you usually need to give them permissions with GRANT.
Passwords should be strong to keep your database secure.
Use SHOW GRANTS FOR 'username'@'host'; to check a user's permissions.
Creating users controls who can access your database.
Use CREATE USER 'name'@'host' IDENTIFIED BY 'password'; to add a user.
Remember to assign permissions after creating the user.
CREATE USER statement in MySQL?CREATE USERCREATE USER command is used to add a new user account to the MySQL server.DROP USER, changing passwords uses ALTER USER, and listing users requires querying system tables.CREATE USER adds users [OK]CREATE USER 'bob'@'localhost' IDENTIFIED BY 'secret';
CREATE USER 'carol' IDENTIFIED BY 'pass123';
CREATE USER 'dave'@'192.168.1.100' IDENTIFIED BY 'safePass!';CREATE USER 'dave'@'192.168.1.100' IDENTIFIED BY 'safePass!'; GRANT SELECT ON employees.* TO 'dave'@'192.168.1.100'; grants SELECT on employees.* to 'dave'@'192.168.1.100', matching the user host. CREATE USER 'dave'@'192.168.1.100' IDENTIFIED BY 'safePass!'; GRANT SELECT ON employees TO 'dave'@'localhost'; grants to 'dave'@'localhost', which is incorrect. Options B and C have wrong host or privileges.Pass the test and this pattern moves unknown