Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql creates a case of ordinary root users and modifies and deletes functions

Shulou Source: shulou.com Published: 2022-06-01 02:43:02 09月12日 Update

Mysql creates a case of ordinary root users and modifies and deletes functions? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

Method 1: use the SET PASSWORD command

Mysql-u root mysql > SET PASSWORD FOR 'root'@'localhost' = PASSWORD (' newpass')

Method 2: use mysqladmin

Mysqladmin-u root password "newpass"

If root has already set a password, use the following methods

Mysqladmin-u root password oldpass "newpass"

Method 3: edit the user table directly with UPDATE

Mysql-u root mysql > use mysql; mysql > UPDATE user SET Password = PASSWORD ('newpass') WHERE user =' root'; mysql > FLUSH PRIVILEGES

Create a normal user

User management

Mysql > use mysql

View

Mysql > select host,user,password from user

Create

Mysql >

User management

Mysql > use mysql

View

Mysql > select host,user,password from user

Create a user

Mysql > insert into mysql.user (Host,User,Password) Values ('%', 'wise',PASSWORD (' passwd')); msyql > FLUSH RPIVILEGES

Modify

You can use mysql > rename user feng to newuser;//mysql 5 later. You need to update the user table using update before.

Delete

When deleting a user before mysql > drop user newuser; / / mysql5, you must first use revoke to delete the user rights, and then delete the user. After mysql5, the drop command can delete the user while deleting the relevant permissions of the user.

Change password

Mysql > set password for zx_root = password ('xxxxxx'); mysql > update mysql.user set password=password (' xxxx') where user='otheruser'

View user permissions

Mysql > show grants for zx_root

Grant authority

Mysql > grant all privileges on YQ.* to wise

Reclaim permission

Mysql > revoke select on dmc_db.* from zx_root; / / an error will be reported if the permission does not exist

Modify

You can use mysql > rename user feng to newuser;//mysql 5 later. You need to update the user table using update before.

Delete

When deleting a user before mysql > dropuser newuser; / / mysql5, you must first use revoke to delete the user rights, and then delete the user. After mysql5, the drop command can delete the user while deleting the relevant permissions of the user.

Change password

Mysql > set password for zx_root = password ('xxxxxx'); mysql > update mysql.user set password=password (' xxxx') where user='otheruser'

View user permissions

Mysql > show grants for zx_root

Grant authority

Mysql > grant select on dmc_db.* to zx_root

Reclaim permission

Mysql > revoke select on dmc_db.* from zx_root; / / if the permission does not exist, an error will be reported. Thank you for reading! After reading the above, do you have a general understanding of mysql's case of creating ordinary root users and modifying and deleting features? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Tags: Users permissions content methods general commands passwords functions cases at the same time articles questions will be reported updated managed more see industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft Linux Apple Shulou Technology