Detailed explanation of mysql permissions and indexes

Detailed explanation of mysql permissions and indexes

mysql permissions and indexes

The highest user of mysql is root.

We can create a user in the database with the statement CREATE USER username IDENTIFIED BY 'password'. We can also execute the CREATE USER username statement to create a user, but this user does not have a password. We can set the password after the user logs in. The statement to delete a user is DROP USER user. The statement to change the username is RENAME USER old username to new username.

Change the password statement to set password=password('password');

The statement for advanced users to modify other users' passwords is SET PASSWORD FOR user=PASSWORD('password'); .

image

There are several operations for granting permissions:

To view user permissions, use the show grants for user statement.

The statement for granting user permissions is grant permission on . to user. The first number represents the database, and the second number represents the table to which permissions are to be granted.

The statement to revoke user privileges is REVOKE CREATE ON . FROM user; the statement to refresh privileges is FLUSH PRIVILEGES.

image

MySQL indexes allow us to find data in the database faster. When we are programming, we can use the column in the condition to design the columns involved in the query as indexes.

There are two types of indexes: ordinary index. Setting it as an ordinary index has no effect on the data in the column, but it optimizes the data search speed; the values ​​in the column set as a unique index are unique, which also optimizes the data search speed; the primary key index is set as the primary key column and the primary key index is automatically added. A table can only have one primary key column, and this column does not allow null values. Generally, the primary key index is created at the same time as the table is created; the full-text index is mainly used to find keywords in the text, rather than directly comparing with the values ​​in the index. The fulltext index is very different from other indexes. It is more like a search engine rather than a simple parameter match of a where statement. The fulltext index is used in conjunction with the match against operation, rather than the general where statement plus like. It can be used in create table, alter table, and create index, but currently only char, varchar, and text columns can be used to create full-text indexes. It is worth mentioning that when the amount of data is large, it is much faster to put the data into a table without a global index and then use CREATE index to create a fulltext index than to first create a fulltext index for a table and then write the data. There is also a composite index, which can combine two columns as conditions for querying together. Using a single column as a condition for querying will not have the effect of an index.

The statement to create an index is CREATE index type [not written as ordinary index] INDEX index name ON table (column).

The statement to delete an index is DROP INDEX index name ON table.

Disadvantages of indexing:

1. Although indexes greatly increase query speed, they also reduce the speed of updating tables, such as inserting, updating, and deleting tables. Because when updating a table, not only the data but also the index file must be saved.

2. Creating an index will take up disk space for index files. Generally this problem is not serious, but if you create multiple combined indexes on a large table, the index file will grow quickly. Indexing is only one factor in improving efficiency. If you have a table with a large amount of data, you need to spend time researching and establishing the best index or optimizing query statements.

image

The above is all the knowledge about MySQL permissions and indexes. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the usage and differences between indexes and views in MySQL
  • Is it necessary to create a separate index for the MySQL partition field column?
  • Detailed explanation of redundant and duplicate indexes in MySQL
  • A brief analysis of mysql index
  • Analysis of MySQL joint index function and usage examples
  • MySql index detailed introduction and correct use method
  • Solve the problem that IN subquery in MySQL will cause the index to be unusable
  • Problems with index and FROM_UNIXTIME in mysql
  • Summary of MySQL's commonly used SQL statements for creating tables, adding fields, modifying fields, and adding indexes
  • How to create an index on a join table in MySQL
  • Tips and precautions for using MySQL index
  • A brief discussion on MySQL index design principles and the differences between common indexes
  • How to add and delete unique indexes for fields in MySQL
  • Related operations of adding and deleting indexes in mysql
  • Detailed explanation of MySQL index operation commands
  • MySQL creates full-text index sharing
  • How to modify a MySQL table to add multiple columns (fields) and indexes at one time
  • Understanding MySQL - Indexing and Optimization Summary

<<:  How to use JavaScript strategy pattern to validate forms

>>:  Use the vue-element-admin framework to dynamically obtain the menu function from the backend

Recommend

Several ways to easily traverse object properties in JS

Table of contents 1. Self-enumerable properties 2...

A detailed introduction to seata docker high availability deployment

Version 1.4.2 Official Documentation dockerhub st...

How to create Apache image using Dockerfile

Table of contents 1. Docker Image 2. Create an in...

Detailed tutorial on using the tomcat8-maven-plugin plugin in Maven

I searched a lot of articles online but didn'...

Do you know how to use Vue to take screenshots of web pages?

Table of contents 1. Install html2Canvas 2. Intro...

MySQL query optimization: a table optimization solution for 1 million data

1. Query speed of two query engines (myIsam engin...

How to customize Docker images using Dockerfile

Customizing images using Dockerfile Image customi...

Installation and use of Ubuntu 18.04 Server version (picture and text)

1 System Installation Steps OS Version:1804 Image...

WeChat Mini Programs Achieve Seamless Scrolling

This article example shares the specific code for...

Using JavaScript difference to implement a comparison tool

Preface At work, I need to count the materials su...

Detailed explanation of linux nslookup command usage

[Who is nslookup?] 】 The nslookup command is a ve...