Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of user method for querying mysql data

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the detailed explanation of the user method of querying mysql data, hoping to supplement and update some knowledge for you. If you have other questions to understand, you can continue to follow my updated article in the industry information.

(1) create a user

The first way to create a user:

Mysql > create user 'wwl' @' localhost' identified by password '123'

# create a user wwl

The second way to create a user: the way to elevate permissions:

Syntax:

Grant all on database. Table to user @ host identified by password

Grant all on *. * to 'test02'@'localhost' identified by' abc123'

Mysql > select password ('123'); # convert the string 123 into encryption

* 23AE809DDACAF96AF0FD78ED04B6A265E05AA257

Mysql > create user 'wwl' @' localhost' identified by password'* 23AE809DDACAF96AF0FD78ED04B6A265E05AA257'

# throw the encrypted string directly into identified by password

# created successfully

Q: where are the new users created now?

Mysql > show databases

Mysql > use mysql

Mysql > show tables

Mysql > select user,password,host from user

⑵ Delete user

Syntax:

Drop user' user' @ 'localhost'

Example:

Drop user 'wangwuliu' @' localhost'

Mysql > drop user 'wwl' @' localhost'

⑶ renames user

Grammar

Rename user 'username to be modified' @ 'localhost' to' new username'@ 'hostname'

Example:

RENAME USER 'wangwuwu' @' localhost' TO 'wangxiaowu' @' localhost'

Set a password for the user

Set password = password ('password'); # modify the current account

SET PASSWORD FOR 'user' @' host' = PASSWORD ('password')

① logs in as a user, such as root, and sets the current user password:

SET PASSWORD = PASSWORD ('12345678')

Mysql > set password = password ('123456')

Mysql > mysql-u root-p

② root users can set passwords for other users:

Syntax:

SET PASSWORD FOR 'wangxiaowu' @' localhost' = PASSWORD ('password')

For example: change the password

Mysql > use mysql

Set password for 'user02'@'localhost' = password (' 123abc')

Mysql > set password for 'hehe' @' localhost' = password ('123456')

The solution when you forget your root password

Direct modification authorization table version 5.7 password modification

# stop the mysqld process

[root@localhost ~] # systemctrl stop mysqld.service

Vim / etc/my.cnf

Insert the last line in [mysqld] mode: save and exit after the skip-grant-tables modification is completed.

Enter the command in mysql

Update mysql.user set authentication_string = password ('123abc') where user='root'

# change root password to 123abc

Before restarting the mysql system, modify the mysql configuration file to delete the content that was previously inserted.

Vim / etc/my.cnf

Restart the mysql system after deletion is completed

You can log in using the modified password 123abc.

-use the Grant statement to grant permissions to the user-

Grant permission list ON library name. Table name TO username @ source address [identified by 'password']

*. *: represents a list of all databases

@ Source address: on which IP or host to use this permission

Identified by 'password': set password

When the authorized user does not exist, the Grant statement creates the user.

MySQL permission list:

ALL: set all permissions except grant option # grant option is to grant permissions

ALTER: allow table modification using alter table #

CREATE: allows you to create tables using create table #

DELETE: allows you to delete rows in a table using delete #

DROP: allows you to delete data tables using drop table #

INSERT: allows the use of insert # to insert new rows into the table

UPDATE: allows you to use update # to modify data in a table

SELECT: allows you to use select # to query data in a table

REPLICATION SLAVE:replication slave reads binary log files from the primary CVM

SHOW DATABASES:show databases displays all databases

Use the SHOW GRANTS statement to view user permissions

Show grants for' user name'@ 'Source address'

Use the revoke statement to revoke the database permissions of the specified user

Revoke permission list on database name. Table name from user name @ Source address

Read the above about the query mysql data user method detailed explanation, hope to bring some help to everyone in the practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report