0
0
MySQLquery~5 mins

Creating users in MySQL - Quick Revision & Summary

Choose your learning style9 modes available
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?
ACREATE USER 'user1'@'localhost' IDENTIFIED BY 'mypassword';
BADD USER 'user1' IDENTIFIED BY 'mypassword';
CNEW USER 'user1'@'localhost' SET PASSWORD 'mypassword';
DCREATE LOGIN 'user1' WITH PASSWORD 'mypassword';
What does the host part in 'username'@'host' specify?
AThe database the user can access
BThe user's role
CThe user's password
DThe IP or machine from which the user can connect
After creating a user, what command applies the changes immediately?
AAPPLY PRIVILEGES;
BUPDATE USERS;
CFLUSH PRIVILEGES;
DRELOAD USERS;
Which command grants all privileges on the database 'shop' to user 'alice'?
AGRANT ALL PRIVILEGES ON shop TO 'alice';
BGRANT ALL PRIVILEGES ON shop.* TO 'alice'@'localhost';
CGRANT ALL ON shop TO 'alice';
DGRANT ALL PRIVILEGES ON shop.* TO 'alice'@'%';
Is it safe to create a MySQL user without a password?
ANo, it is a security risk
BYes, it is safe and recommended
COnly if the user connects from localhost
DOnly if the user has limited privileges
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.