mysql creates root users and ordinary users and modify and delete functions

mysql creates root users and ordinary users and modify and delete functions

Method 1: Use the SET PASSWORD command

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

Method 2: Using mysqladmin

mysqladmin -u root password "newpass"

If the root password has been set, use the following method

mysqladmin -u root password oldpass "newpass"

Method 3: Use UPDATE to edit the user table directly

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;

Check

mysql> select host,user,password from user;

create

mysql>

User Management

mysql>use mysql;

Check

mysql> select host,user,password from user;

Create User

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

Revise

mysql>rename user feng to newuser; //Can be used after mysql 5, before that, you need to use update to update the user table

delete

mysql>drop user newuser; //Before mysql5, you must first use revoke to delete the user's permissions and then delete the user. After mysql5, the drop command can delete the user and the user's related permissions at the same time.

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 permissions

mysql> grant all privileges on YQ.* to wise;

Reclaim Permission

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

Revise

mysql>rename user feng to newuser; //Can be used after mysql 5, before that, you need to use update to update the user table

delete

mysql>dropuser newuser; //Before mysql5, you must first use revoke to delete the user's permissions and then delete the user. After mysql5, the drop command can delete the user and the user's related permissions at the same time.

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 permissions

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

The above is the editor's introduction to MySQL's creation of root users and ordinary users and modification and deletion functions. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • The difference between two MySQL delete user statements (delete user and drop user)
  • MySQL creates users, authorizes users, revokes user permissions, changes user passwords, and deletes users (practical tips)
  • mysql5.7 create user authorization delete user revoke authorization
  • MySql installation and configuration method (MySQL add users, delete users and authorization)
  • Initialize MySQL users (delete anonymous users)
  • User authorization and authorization deletion methods in MySQL
  • Create, authorize, delete, and modify passwords of mysql users in the WIN command prompt
  • Solve the mysql user deletion bug

<<:  Common methods of Vue componentization: component value transfer and communication

>>:  How to Customize Bash Command Prompt in Linux

Recommend

The perfect solution for Vue routing fallback (vue-route-manager)

Table of contents Routing Manager background gett...

CSS3 achieves various border effects

Translucent border Result: Implementation code: &...

How to get form data in Vue

Table of contents need Get data and submit Templa...

Solve the cross-domain problem of get and post requests of vue $http

Vue $http get and post request cross-domain probl...

A brief analysis of the use of watchEffect in Vue3

Preface Everyone should be familiar with the watc...

Some questions about hyperlinks

I am very happy to attend this episode of potato ...

How to use Docker plugin to remotely deploy projects to cloud servers in IDEA

1. Open port 2375 Edit docker.service vim /lib/sy...

How to clean up the disk space occupied by Docker

Docker takes up a lot of space. Whenever we run c...

Detailed explanation of MySQL's Seconds_Behind_Master

Table of contents Seconds_Behind_Master Original ...

Detailed explanation of how to cleanly uninstall Docker

First, the server environment information: Reason...

How to set up remote access to a server by specifying an IP address in Windows

We have many servers that are often interfered wi...

Display mode of elements in CSS

In CSS, element tags are divided into two categor...

Vue+el-table realizes merging cells

This article example shares the specific code of ...