Mysql 5.6 adds a method to modify username and password

Mysql 5.6 adds a method to modify username and password

Log in to MySQL first

shell> mysql --user=root mysql

If you have a password, you need to add the --password or -p option

Adding Users

mysql>CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'finley'@'localhost' WITH GRANT OPTION;
mysql>CREATE USER 'finley'@'%' IDENTIFIED BY 'some_pass';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'finley'@'%' WITH GRANT OPTION;
mysql>CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin_pass';
mysql>GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql>CREATE USER 'dummy'@'localhost';

Add users and set database specific permissions:

mysql>CREATE USER 'custom'@'localhost' IDENTIFIED BY 'obscure';
mysql>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO 'custom'@'localhost';
mysql>CREATE USER 'custom'@'host47.example.com' IDENTIFIED BY 'obscure';
mysql>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON expenses.* TO 'custom'@'host47.example.com';
mysql>CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'obscure';
mysql>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON customer.* TO 'custom'@'%.example.com';

To delete a user:

mysql>DROP USER 'jeffrey'@'localhost';

To change your password:

mysql>SET PASSWORD FOR 'jeffrey'@'localhost' = PASSWORD('mypass');

Modify the password of the currently logged in user:

mysql>SET PASSWORD = PASSWORD('mypass');

The above is the method of adding and modifying usernames and passwords in MySQL 5.6 introduced by the editor. 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:
  • 2 ways to connect to the database directly without entering a username and password

<<:  Summary of the unknown usage of "!" in Linux

>>:  React Hooks Usage Examples

Recommend

Detailed explanation of MySQL binlog usage

binlog is a binary log file that records all DML ...

Docker realizes the connection with the same IP network segment

Recently, I solved the problem of Docker and the ...

Summary of the pitfalls of using primary keys and rowids in MySQL

Preface We may have heard of the concept of rowid...

5 Reasons Why Responsive Web Design Isn’t Worth It

This article is from Tom Ewer's Managewp blog,...

Implementation of react routing guard (routing interception)

React is different from Vue. It implements route ...

Sample code for changing the color of a png image through a CSS3 filter

This method uses the drop-shadow filter in CSS3 t...

Detailed explanation of how to monitor MySQL statements

Quick Reading Why do we need to monitor SQL state...

MySQL 5.7.17 installation and configuration method graphic tutorial under win7

I would like to share with you the graphic tutori...

Vue custom optional time calendar component

This article example shares the specific code of ...

Vue3 (Part 2) Integrating Ant Design Vue

Table of contents 1. Integrate Ant Design Vue 2. ...

js to achieve floor scrolling effect

This article uses jQuery to implement the sliding...

Example analysis of the usage of the new json field type in mysql5.7

This article uses an example to illustrate the us...

Full steps to create a high-performance index in MySQL

Table of contents 1. Index Basics 1. Types of Ind...

Implementation steps for installing java environment in docker

This article is based on Linux centos8 to install...