Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
modul:m290:learningunits:lu06:theorie:01 [2024/10/17 11:44] – vdemir | modul:m290:learningunits:lu06:theorie:01 [2024/11/16 09:00] (aktuell) – kdemirci | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== LU09a - USER Management | + | ====== LU09a - USER and PRIVILEGE |
===== Learning Objectives ===== | ===== Learning Objectives ===== | ||
- Explain why different users are needed to access a database. | - Explain why different users are needed to access a database. | ||
- Create a mysql user on the command line and with a sql script | - Create a mysql user on the command line and with a sql script | ||
+ | - Grant required privileges to the database user newly created | ||
+ | - Revoke privileges from user | ||
- Deleting obsolete user | - Deleting obsolete user | ||
| | ||
- | ==== Introcuction | + | ===== Introduction ===== |
- | In a warehouse | + | In a warehouse |
MySQL user management and privileges are essential for controlling access to the database system, ensuring security, and managing user roles. MySQL allows database administrators (DBAs) to create, manage, and assign permissions to users, limiting what actions users can perform on the database. This control helps protect sensitive data, prevent unauthorized changes, and maintain the overall integrity of the database. | MySQL user management and privileges are essential for controlling access to the database system, ensuring security, and managing user roles. MySQL allows database administrators (DBAs) to create, manage, and assign permissions to users, limiting what actions users can perform on the database. This control helps protect sensitive data, prevent unauthorized changes, and maintain the overall integrity of the database. | ||
- | ==== Key Concepts ==== | + | ===== Key Concepts |
- **User Accounts**: MySQL user accounts are created to define who can log in to the MySQL server and what they can access. Each user is identified by a username and a host, which specifies the IP address or domain from which the user can connect. | - **User Accounts**: MySQL user accounts are created to define who can log in to the MySQL server and what they can access. Each user is identified by a username and a host, which specifies the IP address or domain from which the user can connect. | ||
- **Privileges**: | - **Privileges**: | ||
- **Roles**: MySQL supports roles, which are collections of privileges that can be granted to users as a group. This simplifies managing permissions, | - **Roles**: MySQL supports roles, which are collections of privileges that can be granted to users as a group. This simplifies managing permissions, | ||
- **Authentication**: | - **Authentication**: | ||
+ | |||
+ | ===== Common MySQL User Management Commands ===== | ||
+ | ==== 1. Creating a New User ==== | ||
+ | To create a new user in MySQL, you use the CREATE USER statement: | ||
+ | |||
+ | CREATE USER ' | ||
+ | | ||
+ | This creates a user username that can only connect from localhost (the MySQL server machine). | ||
+ | |||
+ | ** Note ** | ||
+ | |||
+ | MySQL supports several types of password authentication mechanisms. These include: | ||
+ | |||
+ | - **mysql_native_password**: | ||
+ | - **caching_sha2_password**: | ||
+ | - **sha256_password**: | ||
+ | - **auth_socket**: | ||
+ | - **auth_pam**: | ||
+ | - **authentication_ldap_sasl**: | ||
+ | - **authentication_ldap_simple**: | ||
+ | |||
+ | ==== 2. Granting Privileges == | ||
+ | To assign privileges to a user, the GRANT statement is used. For example, to grant a user the ability to SELECT, INSERT, and UPDATE on a specific database: | ||
+ | |||
+ | GRANT SELECT, INSERT, UPDATE ON database_name.* TO ' | ||
+ | | ||
+ | The * symbol specifies that the privileges apply to all tables within database_name. | ||
+ | |||
+ | ==== 3. Viewing User Privileges ==== | ||
+ | You can check a user’s privileges with the SHOW GRANTS command: | ||
+ | |||
+ | SHOW GRANTS FOR ' | ||
+ | | ||
+ | This displays all the privileges granted to the user username. | ||
+ | |||
+ | ==== 4. Revoking Privileges ==== | ||
+ | To remove privileges from a user, the REVOKE statement is used. For example, to revoke the INSERT privilege: | ||
+ | |||
+ | REVOKE INSERT ON database_name.* FROM ' | ||
+ | | ||
+ | ==== 5. Dropping a User ==== | ||
+ | If a user is no longer needed, you can remove the account using the DROP USER statement: | ||
+ | |||
+ | DROP USER ' | ||
+ | | ||
+ | This removes both the user and their associated privileges. | ||
+ | |||
+ | ==== 6. Activating Change of Privileges After Altering Them ==== | ||
+ | To activate changes to privileges in MySQL after modifying them, you can use the following command: | ||
+ | |||
+ | FLUSH PRIVILEGES; | ||
+ | |||
+ | This command forces MySQL to reload the privilege tables, applying any recent changes made to user privileges. Normally, after using GRANT, REVOKE, or ALTER USER, MySQL applies changes automatically, | ||
+ | |||
+ | <color # | ||
+ | |||
+ | | ||
+ | |||
+ | ===== Video-Tutorials ==== | ||
+ | ^How to Create a New User in MySQL |{{: | ||
+ | ^Create User, Grant ReadWrite Privileges and Test Privileges Granted in MySQL |{{: | ||
==== Vocabulary ==== | ==== Vocabulary ==== | ||
Zeile 21: | Zeile 84: | ||
| obsolete | veraltet | | | obsolete | veraltet | | ||
| commodity | Handelsgut, Ware | | | commodity | Handelsgut, Ware | | ||
- | | ... | ... | | + | | to revoke |
---- | ---- | ||
[[https:// | [[https:// | ||