CREATE USER
In this page:
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
एक नया User कैसे बनाएँ
आपके database से connect होने वाले हर person या application के लिए एक dedicated account बनाना, एक login share करने के बजाय, एक core security practice है — CREATE USER इसे set up करने के लिए एक username, एक host, और एक password लेता है।
उदाहरण: How to Create a New User
CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'StrongPass123!';
Host Constraints Specify करना
एक host constraint specify करना exactly restrict करता है कि एक user कहाँ से connect करने के लिए allowed है, चाहे वह एक single IP address हो, एक specific domain, या एक wildcard — इसे lock down करना एक common attack surface बंद कर देता है।
उदाहरण: Specifying Host Constraints
CREATE USER 'app_user'@'192.168.1.10' IDENTIFIED BY 'StrongPass123!';
Authentication Plugins के साथ Users बनाना
MySQL यह manage करने के लिए अलग-अलग authentication plugins support करता है कि passwords कैसे verify होते हैं, और आप creation time पर एक specific plugin चुन सकते हैं जो आपके organization की जो भी security policy माँगती है उससे match करे।
उदाहरण: Creating Users with Authentication Plugins
CREATE USER 'app_user'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'StrongPass123!';
सभी Database Users List करना
अपने database में मौजूद accounts की पूरी list को regularly review करना — mysql system schema query करके — stale या भूले हुए accounts को एक security liability बनने से पहले पकड़ने में मदद करता है।
उदाहरण: Listing All Database Users
SELECT user, host FROM mysql.user;
Password Expiry के साथ Users बनाना
एक newly created account के password को तुरंत expire होने पर force करने का मतलब है कि user को पहली बार login करते समय अपना खुद का password set करना ज़रूरी है, जो एक shared या default password को कभी लंबे समय इस्तेमाल होने से बचाता है।
उदाहरण: Creating Users with Password Expiry
CREATE USER 'temp_user'@'localhost' IDENTIFIED BY 'TempPass123!' PASSWORD EXPIRE;
- host हिस्सा भूल जाना, जैसे
app_user, औरuser@localhostकोuser@'%'से confuse करना। - एक weak password इस्तेमाल करना, या इसे एक ऐसी script में लिखना जिसे दूसरे पढ़ सकें।
- एक user बनाना और उसके access होने की उम्मीद करना, जबकि एक नए user के पास आपके
GRANTकरने तक कोई privileges नहीं होतीं।
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: