You are on page 1of 3

First install mysql-connector or mysql-connector-python through pip or eay_install through cmd or

terminal. Then here are the further steps.

1. To show the current active user enter the command:

Show current_user();

2. To create a new user :

Create user ‘username’@’localhost’

IDENTIFIED WITH (auth plugin) mysql_native_password or


caching_sha2_password(more secure)
BY ‘password’;

3. To check the current user:


Select current_user();
4. To switch between the users go to the mysql server directory then to the bin and open cmd
there by inputting it in location bar the type:
mysql -u username -p
then it will ask for the password and you are done.
This is also the way to open mysql client in cmd.
5. To change the password or the auth plugin:
Alter User ‘username’@’localhost’
IDENTIFIED WITH auth_plugin(new one)
BY ‘new password’;
6. Granting permissions to a new user:
From a root user or from a user who has all privileges we run:
Grant <permission name> on <database name> or “*”. <table name> to
‘username’@’localhost’.
Here * represents all.

7. Removing permissions from user:


Revoke <permission name> on <database name> or < table name> from
‘username’@’localhost’

You might also like