0
0
MySQLquery~20 mins

Creating users in MySQL - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
User Creator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of this user creation query?
Consider the following MySQL command:

CREATE USER 'alice'@'localhost' IDENTIFIED BY 'mypassword';

What will be the result after running this command?
MySQL
CREATE USER 'alice'@'localhost' IDENTIFIED BY 'mypassword';
AUser 'alice' is created and can connect from any host.
BThe user 'alice' is created but without any password set.
CA new user named 'alice' is created with password 'mypassword' and can connect only from localhost.
DSyntax error because password must be hashed before use.
Attempts:
2 left
💡 Hint
Think about what the '@' symbol means in MySQL user creation.
📝 Syntax
intermediate
2:00remaining
Which option has the correct syntax to create a user with host wildcard?
You want to create a user 'bob' who can connect from any host. Which command is syntactically correct?
ACREATE USER 'bob' IDENTIFIED BY 'secret'@'%';
BCREATE USER 'bob'@'%' IDENTIFIED BY 'secret';
CCREATE USER 'bob'@'*' IDENTIFIED BY 'secret';
DCREATE USER 'bob'@'all' IDENTIFIED BY 'secret';
Attempts:
2 left
💡 Hint
The '%' symbol is used as a wildcard for hosts in MySQL.
🔧 Debug
advanced
2:00remaining
Why does this user creation command fail?
Given the command:

CREATE USER 'carol'@'localhost' IDENTIFIED WITH mysql_native_password;

Why does this command fail?
MySQL
CREATE USER 'carol'@'localhost' IDENTIFIED WITH mysql_native_password;
ABecause the IDENTIFIED WITH clause requires a password after the plugin name.
BBecause 'mysql_native_password' is not a valid authentication plugin.
CBecause the user 'carol' already exists.
DBecause the host 'localhost' is invalid.
Attempts:
2 left
💡 Hint
Check the syntax for IDENTIFIED WITH in MySQL user creation.
🧠 Conceptual
advanced
2:00remaining
What does the host part in a MySQL user account specify?
In MySQL, user accounts are defined as 'username'@'host'. What does the 'host' part control?
AIt specifies from which machines the user is allowed to connect.
BIt specifies the user's default database.
CIt specifies the user's password encryption method.
DIt specifies the user's privileges on tables.
Attempts:
2 left
💡 Hint
Think about network connections and security.
optimization
expert
3:00remaining
Which command efficiently creates multiple users with the same password?
You want to create three users: 'dave', 'eve', and 'frank', all connecting from any host, with the password 'pass123'. Which command is the most efficient and valid?
ACREATE USER 'dave'@'%' IDENTIFIED BY 'pass123'; CREATE USER 'eve'@'%' IDENTIFIED BY 'pass123'; CREATE USER 'frank'@'%' IDENTIFIED BY 'pass123';
BCREATE USER 'dave', 'eve', 'frank'@'%' IDENTIFIED BY 'pass123';
CCREATE USER 'dave'@'%', 'eve'@'%', 'frank'@'%' IDENTIFIED BY PASSWORD 'pass123';
DCREATE USER 'dave'@'%', 'eve'@'%', 'frank'@'%' IDENTIFIED BY 'pass123';
Attempts:
2 left
💡 Hint
MySQL allows creating multiple users in one command by listing them with hosts.