Mysql Building Table Common SQL statements personal experience sharing _mysql

Source: Internet
Author: User
Tags create database
Connection: Mysql-h host address-u user name-P user Password (note: U and root can be without spaces, others are the same)
Disconnect: Exit (Enter)

Create authorization: Grant SELECT on database. * To User name @ login host identified by \ "Password \"
Modify Password: mysqladmin-u user name-p old password password new password
Delete authorization: Revoke Select,insert,update,delete om *.* from Test2@localhost;

Display database: show databases;
Display datasheet: show tables;
Display table structure: describe table name;

Creating a library: Create database name;
Delete Library: drop database library name;
Use library (check library): The name of the using library;

Creating Table: Create table table name (field set list);
Delete table: drop table table name;
Modify table: ALTER TABLE t1 rename T2
Query table: SELECT * from table name;
Empty table: Delete from table name;
Backup table: Mysqlbinmysqldump-h (IP)-uroot-p (password) databasename tablename > Tablename.sql
Recovery table: Mysqlbinmysql-h (IP)-uroot-p (password) databasename tablename < Tablename.sql (delete the original table before operation)

Add column: ALTER TABLE T2 add c INT UNSIGNED not NULL auto_increment,add INDEX (c);
Modify column: Alter TABLE T2 MODIFY a TINYINT not NULL, changing b C CHAR (20);
Delete column: ALTER TABLE T2 DROP column C;

Backup database: Mysql\bin\mysqldump-h (IP)-uroot-p (password) databasename > Database.sql
Recovery database: Mysql\bin\mysql-h (IP)-uroot-p (password) DatabaseName < Database.sql
Copy database: Mysql\bin\mysqldump--all-databases > All-databases.sql
Repair Database: Mysqlcheck-a-o-uroot-p54safer

Text data import: Load data local infile \ "filename \" into table name;

Data Import Export: Mysql\bin\mysqlimport database Tables.txt
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.