Marco Study notes five--mysql preliminary

Source: Internet
Author: User

1.mysql

-U USERNAME

-P

-H Mysql_server

Linux:socket

Windows:memory

2. Command categories in interactive mode

Client commands

Server-side commands

You must use the statement terminator, which is the default number

3. Relational database objects:

Table

Index

View

Constraints

Stored Procedures

Storage functions

Trigger

Cursor

User

Permissions

Transaction

4. Common commands

DDL: Database Definition language

Create,alter,drop

DML: Database Administration language

Insert,update,delete

DCL: Database Control Language

Grant,revoke

Create a database

Create DATABASE db_name;

Create DATABASE [if not EXISTS] db_name;

Deleting a database

drop database [if exists] db_name;

Create a table

CREATE TABLE Tb_name (Col1,col2,...);

View the table in the library: show tables from db_name;

View table structure: desc tb_name;

Delete tables: drop table tb_name;

Modify table: ALTER TABLE Tb_name

Modify,change,add,drop

Insert INTO Tb_name (col1,col2,...) values|value (' string ', num,...);

Update tb_name set column=value where condition;

Delete from tb_name where condition;

Select field from Tb_name where condition

*: All fields

Where: No condition indicates all rows are displayed

To create a user:

Create user ' username ' @ ' host ' identified by ' password ';

Drop user ' username ' @ ' host ';

Grant Pri1,pri2,... on Db_name.tb_name to ' username ' @ ' host ' [identified by ' Password '];

Revoke Pri1,pri2,... on Db_name.tb_name from ' username ' @ ' host ';

To view the user's authorization: Show grants for ' username ' @ ' host ';

Flush privileges;

To set a password for a user:

Mysql>set password for ' username ' @ ' host ' =password (' password ');

# mysqladmin-uusername-hhost-p password ' password '

Mysql>update user set Password=password (' Password ') where user= ' root ' and host= ' 127.0.0.1 ';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.