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

JavaScript adds prototype method implementation for built-in objects

The order in which objects call methods: If the m...

Detailed explanation of two points to note in vue3: setup

Table of contents In vue2 In vue3 Notes on setup ...

How to set static IP for Ubuntu 18.04 Server

1. Background Netplan is a new command-line netwo...

Detailed explanation of mysql permissions and indexes

mysql permissions and indexes The highest user of...

js native carousel plug-in production

This article shares the specific code for the js ...

Code for aligning form checkbox and radio text

Alignment issues like type="radio" and t...

Docker configuration Alibaba Cloud image acceleration pull implementation

Today I used docker to pull the image, but the sp...

Detailed explanation of overflow:auto usage

Before starting the main text, I will introduce s...

What are the new CSS :where and :is pseudo-class functions?

What are :is and :where? :is() and :where() are p...

How to use Web front-end vector icons

Preface When writing front-end pages, we often us...

Teach you the detailed process of installing DOClever with Docker Compose

Table of contents 1. What is Docker Compose and h...

Analyze Mysql transactions and data consistency processing issues

This article analyzes the consistency processing ...

How to automatically backup mysql remotely under Linux

Preface: Basically, whether it is for our own use...