11th article: MySQL Basics

Source: Internet
Author: User

The content of this article
    1. MySQL Overview
    2. MySQL Installation
    3. MySQL library Add, delete, change, check
    4. MySQL table Add, delete, change, check
    5. MySQL table record Add, delete, change, check

First, MySQL overview

MySQL is a relational database management system developed by the Swedish MySQL AB Company, currently owned by the Oracle company. MySQL's most popular relational database management system, MySQL is one of the best RDBMS (relational database Management system, relational databases management systems) application software in WEB applications.

MySQL is an associated database management system that keeps data in separate tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software uses a dual licensing policy, which is divided into community and commercial version, due to its small size, fast, low total cost of ownership, especially the open source, the development of the general small and medium-sized web site to choose MySQL as the site database. Thanks to the performance of its community edition, PHP and Apache make a good development environment.

Second, MySQL installation

1.windows:

MySQL version: 5.7.17:http://rj.baidu.com/soft/detail/12585.html?aldwindows download OK, you can click on the file to install it. The installation of Windows is basically the next step.

2.linux:

# Install the Yum source for MySQL, below is the RHEL6 series: RPM-UVH http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm# Installing Yum-config-manager:yum Install yum-utils-y# disable MySQL5.6 Source: Yum-config-manager--disable mysql56-community# Enable source for MySQL5.7: Yum-config-manager--enable mysql57-community-dmr# Use the following command to see if the configuration is correct: Yum Repolist enabled | grep mysql# installation Mysql5.7:yum Install mysql-community-server# disable Selinux:setenforce 0sed-i '/^selinux=/c\selinux=disabled '/etc/selinux/config # starts mysqld, modifies the/ETC/MY.CNF configuration file before starting, this article with the default configuration. Service mysqld Start

Third, MySQL library to increase, delete, change, check

1. Increase of library:

Create database db1 character set UTF8;

With this command we can create a database called DB1, and the character set is Utf-8.

2. Deletion of the library:

Drop database db1;

With this command, we can delete a database called DB1.

3. Changes to the library:

ALTER DATABASE DB1 character set UTF8;

With this command we can change the character set of the database db1.

4. View of the library:

show databases;

With this command we can see the names of all the databases.

5. Opening of the library:

Use DB1

With this command we can open a database with the name DB1.

Iv. MySQL table increase, delete, change, check

1. Increase in the table:

CREATE TABLE  table1 (/                                  * Set ID PRIMARY KEY */  ID INT  PRIMARY key,/                                  * Name field maximum length is 20*/  name VARCHAR (20), /                                  * Set id_1 Uniqueness *  /id_1 INT Unique,                                  /* Set FOREIGN KEY */  FOREIGN key (a_id) REFERENCES A (ID)  );

2. Deletion of the table:

drop TABLE table1;

3. Changes to the table:

(1) Add:

ALTER TABLE table1 add sex varchar (ten) not Null;

(2) Modify, change:

ALTER TABLE table1 change sex varchar (a) Not null;alter table table1 modify sex varchar (a) not Null;

(3) Drop:

ALTER TABLE table1 drop sex;

4. View of the table:

DESC table1;    /* View table structure */show tables;     /* is the database under all table names */show create TABLE table1;    /* View table creation information for the database */
V. MySQL table record increase, delete, change, check

1. Increase in table records:

Insert table1 (id,name,sex) VALUES (1, Yang Lei, male);

2. Deletion of table records:

Delete from table1 where id=1;

3. Changes to the table record:

Update table1 set name= "Small blue"; where id=1

4. View of the table record:

SELECT * FROM table1;    /* Displays all field information for all records */

(1) Where:

SELECT * FROM table1 where id=1;

(2) GROUP by:

(3) Having:

SELECT * FROM table1 GROUP by sex has sex= "male";

(4) Limit:

SELECT * FROM table1 limit 1;

11th article: MySQL Basics

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.