Mysql- database

MYSQL acquaintance:

  • Database Advantages:

    • Stability Program: Program crash will not affect the data and services

    • Data consistency: all the data stored together

    • Concurrency: concurrent database itself

    • Efficiency: CRUD efficient use of database data is higher

  • Database Category:

    • Relational database (table structure):
      • Characteristics of relatively slow, strong correlation between data

      • mysql,oracle,sqlserver,sqllite,accesse

    • Non-relational databases (key: value):
      • Characteristics of relatively fast, small data associated with the data

      • redis, mongodb, memcache (out of - memory level, eliminated),

  • Mysql statement is divided into three types:
    • DDL statements, database definition language: databases, tables, views, indexes, stored procedures, e.g. create, drop, alter

    • DML statements, database manipulation language: insert, delete, update, query data, insert, delete, update, select

    • DCL statement, the database control language: user's access rights, grant, revoke

Mysql installation:

  • Mysql installation:
    • Path can not have Chinese

    • Path can not have special characters

  • InnoDB to create databases and tables generated after file:

    • Database: folder table: File

    • db.opt character set

    • .frm table structure

    • Each tablespace .idb a table (table data and table index)

  • account number:

    • Delete anonymous account (security):

      • drop user ''@localhost;

      • drop user 'root'@'::1';

    • Setting administrator account:

      • 1, using the administrator login: mysql -uroot

      • 2, modify the administrator password: set password = password ( "123");

      • 3, sign-on administrator account: mysql -uroot -p123

    • Create a database account:

      • View created account: select user (); select host, user from mysql.user;

      • Create an account:

        • create user "haiyang"@"192.168.13.%" identified by "123";

        • flush privileges;

      • grant account Empowerment (CRUD):

        • All grant all permissions

        • There is an account Empowerment: grant select on mysql * to "hai" @ "192.168.13%.".

        • No account creation, and give read permission:

          • grant select on mysql.* to "hai"@"192.168.13.%" identified by "123";

        • Create a login ip address specified, you can only specify the ip address can log:

          • mysql -uhaiyang -p123 -h192.168.13.144
      • Permissions can be assigned to the account recovery ........

Database operations:

  • Simple library operations:

    • Create a library: create database ftp;

    • Switch libraries: use the library name;

    • Delete Library: drop database database name;

  • Simple table operations:

    • Creating format: create table table name (id int, name char (character))

    • Create a table: create table table name (id int, name char (12));

    • View Table: show tables;

    • View table structure: desc table; = describe table name;

    • For more information see the table structure: show create table userinfo;

    • View Jian table statement: show create table table name;

    • Delete tables: drop table table name;

    • Modify the table: alter table table name rename haha;

  • CRUD statements:

    • increase

      • Data Insert: insert into table values ​​(1, "haiyang");

      • Insert two: insert into table values ​​(1, "haha"), (2, "dudu");

      • View table data: select * from table name;

    • delete:

      • delete from 表名;

      • Remove the data ID in the table 1: delete from table where id = 1;

    • change:

      • Examples of errors: update userinfo set name = "aa"; (ID is not specified all modifications)

      • The modified table data ID field: update table set name = "fafa" where id = 2;

    • check:

      • delete from 表名;

      • Check all the data in the table: select * from table name;

Guess you like

Origin www.cnblogs.com/haiyang11/p/11266051.html