Get the App
SLTechnology News&Howtos  ›  Database  › 

Modification of mysql login password and introduction of sql statement

Shulou Source: shulou.com Published: 2022-06-01 04:07:23 09月21日 Update

Change the mysql login password:

In the process of using the database server, you may forget your login password for various reasons, or you may need to use someone else's database server, but others may forget your login password and so on.

There are two ways to forget your password. One is to change the login password through the sql statement:

Second, by modifying the my.ini configuration file under the mysql installation directory, find [mysqld] in the configuration file, and then write a sentence below: sikp-grant-tables. Then restart the database server, and you can skip password verification.

Example:

1.

two。

Sql statement type:

DDL: structure creation statements that can create, delete, modify, index, view, stored procedures, shape structures

DML: data update statement, specializing in manipulating data, and the operation is limited, the basic operation of the data in the table. The main function is to add, delete, check and change, most of which are using query statements.

DQL, a branch of DML: query statement, which is responsible for query

DCL: the statement to control and manipulate the database

Basic statement:

Show databases; shows how many databases are in the database server.

Use database name; connect to a database and select a database.

Show tables; displays all table names in the selected database.

Desc table name; shows the structure of the table (some databases can support it).

Exit; exits the database console.

Quit; exits the database console.

Show databases; code example:

Use database name; code example:

Show tables; code example:

Desc table name; code example:

Exit; code example (in the same way as quit):

DDL type statement:

There is a database before a table, so you need to create a database first. The sql statement to create a database is: create database database name

After you have created a database, you can create a table in it. The sql statement to create the table is:

CREATE TABLE table name (

Column name type characteristics

Column name type characteristics

);

Example:

Code example:

An introduction to common data types, of which those marked in red are the most commonly used:

Char text type

Varchar string with a total length of 3000

Decimal (5Pol 2) indicates that the total length of the number is 5 digits, with 2 decimal places.

The total length of int is 11

Bit only has 0 and 1

Date YMD format date type

Datetime date + time type

Booleam Boolean type

Double double precision floating point type

Float floating point type

Text large text type, how many megabytes of data can be put

Long long integer

What is the primary key and what is the meaning of the primary key?

The table we just created has a structural problem, and the performance is quite poor because we don't write the primary key. What is the primary key? When a column is declared as a primary key, the value of the column is unique and cannot be repeated.

The significance of the primary key is to establish a directory of data for us to delete, add, modify, a single query, etc., you can operate according to the primary key. Because the value of the primary key is unique, it is much faster to operate.

Code example:

Joint primary key:

A federated primary key is that multiple columns can be used as primary keys.

Code example:

Tags: Data database type statement example code password table login server structure service query control that is commonly used meaning console file text Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi vpn NVidia Shulou Information Apple