Mysql account management and engine

Table of contents

mysql metabase

Database account management

1. Create an account

2. Check the account

3. Delete account

4. Change the password

5. Refresh the configuration

6. Set permissions

7. View permissions

8. Revocation of permissions

mysql engine

Some commonly used engines

1. MyISAM engine

2, memory engine

3. InnoDB engine

4. Archive engine


mysql metabase

What is a metabase: a database that records mysql's own data

What databases are there: information_schema (information database ), which stores other database information maintained by mysql, such as database name, database table, data type and access authority of table column, etc.
                         mysql (core database) , mainly responsible for storing database users, Permission settings, keywords and other control and management information that mysql needs to use
                         performance_schema  is used for the storage of mysql monitoring data

Switch database: use database name    such as: use mysql

Database account management

1. Create an account

Naming format: create user username identified by 'password'

Description: identified by will encrypt the plaintext password and store it as a hash value


Example: create user test identified by '123456';

2. Check the account

Command format: select host,user,password from user;


host column description:  % (match all hosts)
                      localhost  (localhost will not be resolved into an IP address, directly connected through UNIX socket; the same host communicates without going through the network protocol stack, without packing and unpacking, calculating checksum, maintaining serial number response etc. Just copy application layer data from one process to another)
                      127.0.0.1 (will be connected through TCP/IP protocol and can only be accessed locally)
                       ::1 (::1 is compatible with ipv6 support, indicating that 127.0.0.1 with ipv4)

3. Delete account

Command format: drop user username

Example: drop user test;

Note: generally not used, please be careful when using

4. Change the password

Command format
    set password for username=password('new password')
Example:
    set password for test=password('123456');

5. Refresh the configuration

Command format: flush privileges

6. Set permissions

Command format:

grant privileges on databasename.tablename to username@'host'

privileges : Specify permissions such as select, update, etc., use all for all permissions

databasename : specify the database, all databases please use *
tablename : specify the data table, all tables please use *
username : the username that needs to be empowered, @ with Host means that the empowerment operation is for those links, see [host column description for details] 】

Example of use

//将bookshop数据库中的t_book表的select,update权限赋予test用户,并且不对ip地址限制
grant select, update on bookshop.`t_book` TO test@'%';

//一般用于赋予管理员最高权限,谨慎使用
grant all on *.* to dba@'localhost'

//以192.168.0开头的账户名deveoper用户针对testdb数据库赋予创建视图的权限
grant create view on testdb.* to developer@'192.168.0.%'; 

//以192.168.0开头的账户名deveoper用户针对testdb数据库赋予查看视图的权限
grant show   view on testdb.* to developer@'192.168.0.%'

//以192.168.0开头的账户名deveoper用户针对testdb数据库赋予创建索引的权限
grant index on testdb.* to developer@'192.168.0.%';

//以192.168.0开头的账户名deveoper用户针对testdb数据库赋予操作存储过程与函数的权限
//以192.168.0开头的账户名deveoper用户针对testdb数据库赋予创建删除存储过程与函数的权限
grant create routine on testdb.* to developer@'192.168.0.%'
grant alter  routine on testdb.* to developer@'192.168.0.%';

Authorized users can assign the permissions they have to other users

Command format:

grant privileges on databasename.tablename to username@'host' with grant option

Example:

grant select on testdb.* to dba@localhost with grant option

Note: Generally not used, it is recommended to manage unified management with the database administrator (DBA).

7. View permissions

show grants: View the current user (own) permissions
show grants for dba@localhost;

View other MySQL user permissions

8. Revocation of permissions

Command format:

revoke privileges on databasename.tablename from username@'host'

Example:

revoke update on bookshop.t_book from test@'%';
//收回test用户对于bookshop库中t_book表的update权限(ip不限)

mysql engine

What is a database engine?

The database storage engine is the underlying software organization of the database. The database management system (DBMS) uses the data engine to create, query, update and delete data. Different storage engines provide different storage mechanisms, indexing skills, locking levels and other functions, and use different storage engines. engine, but also to obtain specific functions

View Data Engine

Command: show engines
Support Field description: DEFAULT is the default engine

                               YES means it can be used
                               , NO means it cannot be used

Some commonly used engines

1. MyISAM engine

MYISAM emphasizes fast read operations

Usage scenarios: scenarios with a large number of queries and few modifications
Storage limit: 256T
Transaction support: Transactions are not supported

2, memory engine

All data is stored in memory. Once the server is restarted, all the table data of the Memory storage engine will disappear but the table structure will be preserved.
Usage scenario: Due to volatility, it can be used to store intermediate tables generated in the analysis.
Storage limitations: Depends on RAM
transaction support: Transactions are not supported

3. InnoDB engine

The latter is quick to modify and supports transactions
. Usage scenario: general transactional, all use this engine, which is the most widely used. If you are not sure which engine to use, use this engine.
Storage limit: 64TG
Transaction support: support transactions

4. Archive engine

Only insert and query are allowed, modification and deletion are not allowed, storage is compressed, space saving, high concurrent insertion can be achieved, and indexing on auto-incrementing ids is supported.
Usage scenarios :
Features can be used in log and data
    collection ; The MyISAM table is about 75% smaller, about 83% smaller than the InnoDB table that supports transaction processing. It
    does not support indexes (except for the auto-increment id column).
    It supports insert and select operations, but does not support delete and update operations.

Guess you like

Origin blog.csdn.net/qq_64001795/article/details/125938104