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

User who created the Mysql database

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Note: the SQL statement ends with ";" by default in the Mysql database. When entering commands, keywords can be uppercase or lowercase, but must be consistent, I prefer to use lowercase, personal habit.

There are three main ways to create database users in Mysql:

1 by inserting data records into the user table of the mysql library (Note: mysql users are saved in the user table by default):

Mysql > insert into user (name,passwd) values ('zwj','abcdefg')

Description:

Insert into: keyword

User: table name, followed by field name in parentheses

Values: keyword followed by the value of the field in parentheses

After you have created a user, you can view the established user: mysql > select * from mysql.user

In general, it is not recommended to create users in the above way (too amateur)

2 use the create user statement to create a user:

Mysql > create user't 100 million dollars 127.0.0.1 'identified by't 100

Description:

Create user: keyword

T100: user name

127.0.0.1: source address, which represents the local machine, or can be written as a network segment such as 192.168.10.%

Identified by: the keyword used to set the password. If omitted, the password is empty.

After the user is established, authorization is required, otherwise most operations will not be possible except to connect to the database.

3 use the grant statement to create a user and grant permissions:

Mysql > grant select on mysql.* to 't100' identified by 't100'

Description:

Grant: keyword

Select: permissions for query

On: keyword

All tables under the mysql.*:mysql library. * is a wildcard that represents all.

The above statement means: create a user t110 that allows the client from 192.168.10.1 to access this database and grant the right to query.

Users need to refresh the permission table after they are built:

Mysql > flush privileges

View permission: mysql > show grants for 't100 requests permission 192.168.10.1'

Revoke permissions: mysql > revoke select on mysql.* from 't100 revoked permissions 192.168.10.1'

The third way is the more common way of creating users and authorizations.

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

Database

Wechat

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

12
Report