MySQL User Administration - Creating new users, logging in with them , and dropping users.
Learn how to create a new user and explore multiple methods to connect to mysql with that user. Additionally, discover the steps to delete a user when no loner needed.
Let's look at the steps to create a MySQL user:
Step 1: First let's check what options are available when creating a user.
help create user;
Step 2: To create user execute this command:
create user if not exists 'user_name' identified by 'password' password expire never account unlock;
Step 3: Now let's grant the permissions to the user. In this case we are granting all the privileges to the user.
grant all privileges on *.* to 'junior' with grant option;
Step 4: Flush the privileges.
flush privileges;
(To reload the privileges, ensuring any changes made to the account take effect immediately)
Step 5: To confirm whether all privileges are granted:
show grants for user_name;
Now the question arises: how do we connect to mysql with the new user which we have just created through the terminal?
We can do this by executing the following query:
mysql --host=<your-ip-address> --user=user_name --password








Comments
Post a Comment