To create, delete, assign permission user on mysql
How to create, delete, assign permission on user in MySQL.
Today we will learn how to create, delete, assign permission and change on users in MySQL. It's very easy to create, delete and so on in MySQL and hope this helps you to resolve your query.
To create and delete user on mysql |
Following the all MySQL command to create users, delete and assign permission:
To check user account on MySQL
SELECT USER, HOST FROM mysql.user;
To delete User account from localhost
DROP USER 'Test'@'localhost';
To delete user account from %
DROP USER 'Test'@'%';
To create New user
CREATE USER 'test'@'localhost' IDENTIFIED BY 'mypassword';
To assign global privileges, use ON *.* syntax
GRANT ALL ON *.* TO 'anyuser'@'localhost';
GRANT SELECT, INSERT ON *.* TO 'anyuser'@'localhost';
To assign database-level privileges, use ON db_name.* syntax:
GRANT ALL ON mydb.* TO 'anyuser'@'localhost';
GRANT SELECT, INSERT ON mydb.* TO 'anyuser'@'localhost';
To Rename user Syntax
RENAME USER 'test'@'localhost' TO 'test'@'127.0.0.1';
To change an account's password and expire it
ALTER USER 'test'@'localhost' IDENTIFIED BY 'new_password' PASSWORD EXPIRE;
To require that a new password be chosen every 180 days
ALTER USER 'test'@'localhost' IDENTIFIED WITH sha256_password BY 'new_password' PASSWORD EXPIRE INTERVAL 180 DAY;
To lock or unlock an account:
ALTER USER 'test'@'localhost' ACCOUNT LOCK;
ALTER USER 'test'@'localhost' ACCOUNT UNLOCK;
To delete User account from localhost
DROP USER 'Test'@'localhost';
To delete user account from %
DROP USER 'Test'@'%';
To create New user
CREATE USER 'test'@'localhost' IDENTIFIED BY 'mypassword';
To assign global privileges, use ON *.* syntax
GRANT ALL ON *.* TO 'anyuser'@'localhost';
GRANT SELECT, INSERT ON *.* TO 'anyuser'@'localhost';
To assign database-level privileges, use ON db_name.* syntax:
GRANT ALL ON mydb.* TO 'anyuser'@'localhost';
GRANT SELECT, INSERT ON mydb.* TO 'anyuser'@'localhost';
To Rename user Syntax
RENAME USER 'test'@'localhost' TO 'test'@'127.0.0.1';
To change an account's password and expire it
ALTER USER 'test'@'localhost' IDENTIFIED BY 'new_password' PASSWORD EXPIRE;
To require that a new password be chosen every 180 days
ALTER USER 'test'@'localhost' IDENTIFIED WITH sha256_password BY 'new_password' PASSWORD EXPIRE INTERVAL 180 DAY;
To lock or unlock an account:
ALTER USER 'test'@'localhost' ACCOUNT LOCK;
ALTER USER 'test'@'localhost' ACCOUNT UNLOCK;
To modify on user for Password Expire
ALTER USER 'test'@'localhost' PASSWORD EXPIRE DEFAULT;
To modify on user for Password never Expire
ALTER USER 'test'@'localhost' PASSWORD EXPIRE NEVER;
To modify on user for Password Expire Interval N(Number of Day) Day
ALTER USER 'test'@'localhost' PASSWORD EXPIRE INTERVAL 180 DAY;
To refer to the account associated with the current session.
ALTER USER USER() IDENTIFIED BY 'auth_string';
Hope this will help to all of you and resolved your all query if you have any query or question so you may ask to send email on our email account (onlinenetworkssolution@gmail.com) or leave comment on page.
Tags:
MySQL
0 comments
Please leave your comments...... Thanks