Install and use MySQL

Source: Internet
Author: User

Http://wenku.baidu.com/view/3f7319a4f524ccbff1218468.html


1. Install

Http://www.cnblogs.com/276815076/archive/2012/04/01/2428364.html

Installation Package

Sudo apt-get install mysql-server

Set root Password

Mysqladmin-u root password 'abc123'-p

2. configure the mysql to accept connection from outside.
In/etc/mysql/my. cnf change this:
Bind-address = 127.0.0.1
To
Bind-address = 0.0.0.0

3. configure mysql to accept root connection from remote host
Grant all privileges on *. * to 'root' @ '%' identified by 'passwd' with grant option;

This method is transferred from http://www.cnblogs.com/wliang22/archive/2009/11/13/1602423.html

4. Create a user

Create user abc;

2. Create/select a database

Create database dev;

Show databases;

Use dev;

Drop database dev;

Delete a database.

3. Display/create a table

Show tables;

Create table pet (name varchar (20), owner varchar (20), species varchar (20), sex char (1), birth date, death date );

Describe pet;

+ --------- + ------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ --------- + ------------- + ------ + ----- + --------- + ------- +
| Name | varchar (20) | YES | NULL |
| Owner | varchar (20) | YES | NULL |
| Species | varchar (20) | YES | NULL |
| Sex | char (1) | YES | NULL |
| Birth | date | YES | NULL |
| Death | date | YES | NULL |
+ --------- + ------------- + ------ + ----- + --------- + ------- +

Drop table pet;

Delete table

4. Import table data from a file

5. data input and reading

Insert into pet values ('puffball', 'diane ', 'hamster', 'F', '2017-02-01', NULL );

Select * from pet;

The select format is

Select what_to_select

From which_table

Where conditions_to_satisfy

SelectDistinctOwner from pet;

Duplicate items are not displayed.

Select name, birth from petOrderBirth;

Sort

6. Delete table content

Delete from pet;

7. Update table records

Update pet set death = '2017-09-08 'where name = 'puffball ';

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.