Recall & Review
beginner
What is the basic SQL command to create a new user in MySQL?
The basic command is
CREATE USER 'username'@'host' IDENTIFIED BY 'password'; where you specify the username, host, and password.Click to reveal answer
beginner
Why do you need to specify the host when creating a MySQL user?
The host defines where the user can connect from. For example,
'localhost' means the user can only connect from the local machine.Click to reveal answer
intermediate
How do you grant all privileges on a database to a user after creating them?
Use
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'host'; to give full access to that database.Click to reveal answer
intermediate
What command do you use to apply changes after creating or modifying users in MySQL?
Run
FLUSH PRIVILEGES; to reload the grant tables and apply changes immediately.Click to reveal answer
beginner
Can you create a user without a password in MySQL? What is the risk?
Yes, but it is not recommended because it allows anyone to connect without authentication, which is a security risk.
Click to reveal answer
Which command creates a new MySQL user with password 'mypassword' for localhost?
✗ Incorrect
The correct syntax is CREATE USER with username, host, and IDENTIFIED BY password.
What does the host part in 'username'@'host' specify?
✗ Incorrect
The host defines where the user is allowed to connect from.
After creating a user, what command applies the changes immediately?
✗ Incorrect
FLUSH PRIVILEGES reloads the grant tables to apply changes.
Which command grants all privileges on the database 'shop' to user 'alice'?
✗ Incorrect
You must specify the database with .* and the user with host.
Is it safe to create a MySQL user without a password?
✗ Incorrect
Users without passwords can connect without authentication, which is unsafe.
Explain the steps to create a new MySQL user and give them full access to a specific database.
Think about creating the user, granting rights, then applying changes.
You got /3 concepts.
Why is specifying the host important when creating a MySQL user?
Consider how MySQL controls user connections.
You got /3 concepts.