To manipulate commands in the Ubuntu system:
Login: Mysql-uroot-p
Start: Service MySQL Start
STOP: Service MySQL stop
Restart: Service MySQL restart
Creating database: Create database name charset = UTF8;
Delete databases: drop database name;
View all databases: show databases;
Using database: Use database name;
View the currently used databases: Select database ();
Change Database Password: Update mysql.user set Authentication_string=password (' root ') where user= ' root ';
Build Table command:
CREATE TABLE table name (Columns ... );
Unique identity (primary key): ID,
Type: int unsigned,
Constraint 1:not NULL,
Constraint 2:auto_increment,
Constraint 3:primary key
Format of column: column name, type, constraint
Such as:
CREATE TABLE Students (
ID int auto_increment PRIMARY key NOT NULL,
Name varchar (10),
Gender bit default 1,
Birthday datetime,
Isdelete bit default 0
);
View all tables: show tables;
View table structure: DESC table name;
Modify table: ALTER TABLE name add|modify|drop column name type constraint;
ALTER TABLE students modify column Isdelete bit not null default 0;
Change table name: Rename table name to new table name;
Delete tables: drop table name;
View creation Statement for table: Show create table ' table name ';
Add data: INSERT into table table name (column name) values (value), (value) ...;
Modify data: Update table name set column 1 = value 1 ... Where condition;
Delete data: Delete from table name where condition;
Generally do not do physical deletion, do the logical deletion;
Tombstone: Update ...;
Backup: Mysqldump-uroot-p database name > file name. sql
Recovery: Mysql-uroot-p Database name < file name. sql
MySQL basic command 1