Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of how to reset password and assign New user Rights in mysql

Shulou Source: shulou.com Published: 2022-06-01 18:05:41 09月21日 Update

This article is mainly about how to reset passwords and assign new user rights in mysql. If you are interested, let's take a look at this article. I believe it is of some reference value to you after reading how to reset passwords and assign new user rights in mysql.

1. Reset the root password

1. Modify the configuration file and log in without secret

Enter the command to edit the file sudo vi etc/mysql/my.cnf (root users can do without sudo)

Edit the file and write to the configuration:

[mysqld] skip-grant-tables

Restart mysql after wq save and exit:

Sudo service mysql restart

Log in to mysql

Change the password:

UPDATE mysql.user SET authentication_string=PASSWORD ("123") WHERE user= "root"; flush privileges

Finally, exit and delete the code added by my.cnf, and then restart mysql and you are done.

Create a user and assign table permissions

Create a user

CREATE USER 'user2'@'localhost' IDENTIFIED BY' 123'

Create a tabl

Create database test

Assign permissions

Grant all privileges on test.* to user2@'%' identified by '123'

Refresh the system permissions table

Flush privileges

View permissions:

Show grants for 'user2'@'%'

Exit restart mysql

Are the above details about how to reset passwords and assign new user rights in mysql helpful? If you want to know more about it, you can continue to follow our industry information section.

Tags: Permissions users passwords assignments methods files content login configuration done code value interest commands great achievements articles more sections articles system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology Huawei Redmi Xiaomi