MySQL basic command 1

Source: Internet
Author: User

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

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.