MySQL Common commands summary (1)

Source: Internet
Author: User

1. Connect MySQL

Format: mysql-h host address-u user name-P user Password

1.1. Connect to MySQL on this machine.

First open the DOS window, then enter the directory Mysql/bin, and then type the command mysql-u root-p, enter the password prompt. The prompt for MySQL is: mysql>

1.2. Connect to MySQL on the remote host. Assume that the remote host IP is: 10.10.10.10, the user name is root, the password is 123. Type the following command:

Mysql-h10.10.10.10-u Root-p 123; (Note: You can not add a space between the root and the other)

1.3. Exit MySQL command: Exit (enter)


2, about the database command

2.1, create the database (SQL statement must have;)

Mysql>create database databasename;

2.2. Connect to the database:

Mysql>use DatabaseName;

2.3. Display database:

Mysql>show databases;

2.4. Delete the database:

Mysql>drop database databasename;


3. Commands for data tables

3.1. View the tables in the database:

Mysql>show tables;

3.2. Description Table structure:

Mysql>describe TableName;

3.3. Modify the type of Table property:

Mysql>alter Table tablename Modify field property to be modified to the type;

3.4. Renaming indicates:

Mysql>rename table Old_tablename to New_tablename,


4, about the list of data table partition

4.1, first need to see whether the current database supports partitioning

Mysql>show variables like '%partition% ';

4.2. Add Table partition:

Example:

ALTER TABLE wc_day66

Partitionby list [columns] (region)

(

Partition P1 values in (0),

Partition P2 values in (1),

Partition P3 values in (2),

Partition P4 values in (3)

);

4.3. Delete the partition:

Example:

ALTER TABLE wc_day66 drop partition p1;

This article is from the "Fire Blue" blog, be sure to keep this source http://fireblue.blog.51cto.com/9934670/1693661

MySQL Common commands summary (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.