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

Detailed explanation of the JavaScript timer principle

Table of contents 1. setTimeout() timer 2. Stop t...

Summary of 11 common mistakes made by MySQL call novices

Preface You may often receive warning emails from...

Alibaba Cloud Centos7 installation and configuration of SVN

1. Install SVN server yum install subversion 2. C...

How to design and create adaptive web pages

With the popularization of 3G, more and more peop...

JavaScript Design Pattern Command Pattern

The command pattern is a behavioral design patter...

The "3I" Standards for Successful Print Advertising

For many domestic advertisers, the creation and ev...

MySQL 5.7.18 Green Edition Download and Installation Tutorial

This article records the detailed process of down...

Linux CentOS6.9 installation graphic tutorial under VMware

As a technical novice, I am recording the process...

Vue+Vant implements the top search bar

This article example shares the specific code of ...

Two methods to disable form controls in HTML: readonly and disabled

In the process of making web pages, we often use f...

Graphic tutorial on configuring log server in Linux

Preface This article mainly introduces the releva...

Tutorial diagram of installing zabbix2.4 under centos6.5

The fixed IP address of the centos-DVD1 version s...