Database Operations (DB)

Source: Internet
Author: User

1. Connect to the database

Win+r > cmd > Mysql-h localhost-uroot-p


2, the operation of the database

    • Creating database: Create database name;

    • Remove database: drop database name;

    • Show databases: Show databases;

    • Using database: Use database name;


3. Table operation

  • Show All tables: show tables;

  • Delete tables: drop table name;

  • Creating Table: Create table table name (ID int (one) unsigned NOT NULL Auto_increment primary key,

    • Username varchar (+),

    • Userpwd varchar (+),

    • Email varchar [Remember there is no ","]

    • ) ;

  • Display table structure: DESC table name;

  • Show CREATE TABLE statement: Show creates table table name;

  • Modify the name of the data table: ALTER TABLE name rename as new table name;

4. Table Data operation:

  • Insert Data: Insert into Table name (Field 1, Field 2 、、、) Values (value 1, value 2 、、、);

  • query data: select * from where   condition limit 0.1];

  • To Modify the data: Update Table name Set Field name 1= value 1, field name 2= value 2 、、、 where conditions;

  • Delete data: Delete from Table name where conditions;

  • Authorized User rights: GRANT permissions on the database. Data table to User name @ login host identified by "password"

    • For example: Add a new user named Lisi, and the password is string "123".

    • Allow him to log on to any host and have access to queries, insertions, modifications, and deletions to all databases.

    • The first thing to do is log in as the root user

    • Then enter the following command:

    • GRANT select,insert,update,delete On * * to [e-mail protected] "%" identified by "123"

5, temporarily change the encoding format to GBK:set names GBK;

6. Common operation of MySQL database:

We can use the help command to query for shortcut keys:

Set up the data after the query: \g

Cancel the currently unfinished operation: \c

Exit Current client: \q exit

Show current server Status: \s

Display Help information for: \h (same as assist command)

Change performer: \d

DOS command: Clear screen CLS


This article is from the PHP Learning notes blog, so be sure to keep this source http://phpst.blog.51cto.com/6922579/1557927

Database Operations (DB)

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.