0
0
MySQLquery~30 mins

Creating users in MySQL - Try It Yourself

Choose your learning style9 modes available
Creating users
📖 Scenario: You are setting up a new database system for a small company. You need to create user accounts with specific permissions to control access to the database.
🎯 Goal: Create new users in MySQL with specific usernames and passwords, and grant them basic permissions.
📋 What You'll Learn
Create a user with a given username and password
Create a second user with a different username and password
Grant SELECT permission on a database to the first user
Grant ALL privileges on a database to the second user
💡 Why This Matters
🌍 Real World
Creating users and managing their permissions is essential for database security and access control in any organization.
💼 Career
Database administrators and backend developers often create and manage database users to ensure proper access and protect sensitive data.
Progress0 / 4 steps
1
Create the first user
Write a MySQL statement to create a user named 'user1' with the password 'password1'.
MySQL
Need a hint?

Use the CREATE USER statement with the username and password exactly as shown.

2
Create the second user
Write a MySQL statement to create a user named 'user2' with the password 'password2'.
MySQL
Need a hint?

Use the CREATE USER statement again with the new username and password.

3
Grant SELECT permission to the first user
Write a MySQL statement to grant SELECT permission on the database company_db to the user 'user1'.
MySQL
Need a hint?

Use the GRANT SELECT ON database.* TO user syntax to give read-only access.

4
Grant ALL privileges to the second user
Write a MySQL statement to grant ALL privileges on the database company_db to the user 'user2'.
MySQL
Need a hint?

Use the GRANT ALL PRIVILEGES ON database.* TO user syntax to give full access.