MySQL database detailed (Ubuntu 14.0.4 LTS 64)

Source: Internet
Author: User
Today for you to review the concept of MySQL, detailed analysis of the Ubuntu 14.0.4 LTS 64-bit MySQL, the need for friends can refer to.

The composition and related concepts of 1.mysql database

First understand that MySQL is a relational database, and the biggest difference in non-relational database is the concept of the table is not the same.

+ The entire MySQL environment can be understood as one of the largest databases: a

+ database B created with MySQL is a, a warehouse of data, equivalent to a folder in the system

+ Data Table C: Is the location of the data, equivalent to the file in the system, a database B contains a number of data table C (Note that there is a different database B and a)

+ record D: A row in a data table is called a record, so when we create a data table, be sure to create an ID column that identifies "this is the number of records", the value of the ID column cannot be the same, and must be unique, equivalent to the identity card number. A table C can have multiple records D

+ field E: Each column in a table is called a "field", and each field in the database is specified, such as: The data type of the field, the determination of null and void, the automatic growth, and so on. A record D can have more than one field E.

+ Data F: the intersection of rows and columns is the real "data" F.

2. Basic operation of the database (Ubuntu Environment) Common command instances.

2.1 Login Mysql:mysql-uroot-p-u: Login with user name,-P: Enter password


2.2 View the database: Enter the above command will be required to enter the password, the successful login will display the interface, see System A comes with data b

showdatabases; Note that semicolons should not be less, as shown in the system's own database.


2.3 Creating the database: Create databases mytest; This creates a database B, and the library is named MyTest.


2.4 In the above 4 databases, how to choose the database we want? Usemytest, this selects our database mytest.


2.5 If you want to delete the database: dropdatabasemytest This will delete the database and will not be alerted.

2.6 View current status: status;


2.7 shows the table C in the current database in the following two ways. A:showtables;b:showtablesfrommytest;. Where MyTest is the database we set up.


2.8 Data Sheet creation and deletion

Createtablemytable (Idint,nameint);

droptablemytable;


2.9 How to build a good data table, that is, how to insert data into a data table? Insertintomytable (Id,name) values (1,10);

2.10 Query the data in the table, Selectid,namefrommytablewhereid=1order; or select*frommytable


2.11 Update of data in table, update mytable set name=20 where id=1;


2.12 Deletion of the table: deletefrommytable; or droptablemytable;

2.13 Modification of the table structure

(1) Add a field format:

Altertabletable_nameaddcolumn (field name fields type);--this method with parentheses

(2) Specify where the field is inserted:

Altertabletable_nameaddcolumn field name fields type after a field;

(3) Modify field name/type

Altertabletable_namechange old field name new field name the type of the new field;

(4) Change the name of the table

Altertabletable_namerenametonew_table_name;

(5) Clear all data in the table at once

This method also causes the Truncatetabletable_name (ID) in the table to start at 1

(6) Delete a field:

Altertabletable_namedrop field name;

2.14 Change Password Format: Mysqladmin-u username-P Old password password new password;

2.15 Structure of the display table: Describemytables;


2.16 shows the current database and user show (); Show user ();


3 Note:

3.1 If you hit the command, the return after the discovery forgot to add a semicolon, you do not have to re-play the command, as long as a semicolon to enter the return on it.

3.2 You can use the cursor up and down keys to bring up previous commands.


Believe that you have seen these cases you have mastered the method, more wonderful please pay attention to the PHP Chinese network other related articles!

Related reading:

Ajax implementation of a simple registration page asynchronous request Instance code

Using Jquery+ajax in PHP for paging query function

Example of AJAX implementation of no flush upload file function

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.