Teach you how to play MySQL for 3 minutes

Source: Internet
Author: User

Operation MySQL

1. Connect MySQL

Mysql-u Root

2. Set the password for the root user

" www.1.com "

3. After setting the password for the user, connect MySQL

Mysql-u root-p

4. mysql connecting to other servers

Mysql-u root-p-H IP Address

5. View the database

show databases;

6. Switch database

Use database name;

7. View Data Sheet

Show tables;

8. View the structure of the table

desc [table name];   

9. Create a Database

Note: If you join the integrity constraint here, please refer to the blog: http://www.cnblogs.com/renfanzi/p/5613235.html

Create DATABASE [DB name];d ROP database [DB name];

10. Create a data table

CREATE table [table name] (field 1 type [parameter], field 2 Type [parameter]);d ROP table [table name];
Data management--increase, delete, change, check

Note: If you join the integrity constraint here, please refer to the blog: http://www.cnblogs.com/renfanzi/p/5613235.html

1) Add data

Insert into table name values (value 1, value 2, value 3), insert into table name (field name, field name) values  (value 1, value 2); Note: If the field type is char or varchar, the field value is enclosed in single quotation marks.

2) Delete data

From fromwhere sex='W';

3) Modify the data

Set where condition;

4) Query data

Select* fromtable name;SelectField name, field name fromstudent;Select* fromStudentwhereName='Lisi'and sex='M';Select* fromStudentwhereName='Lisi'or sex='M';
Database management

1) Rights Management

Authorized

Grant permissions on the Library name. Table Name to'User name'@'IP Address'Identified by'Password'; Permissions:Select, Update,delete,insert all represents all rights IP addresses:'192.168.1.1'                   '192.168.1.%'GrantSelectOn S284.student to'Admin'@'localhost'Identified by'www.1.com'; # mysql-U admin-h10.1.1.1-P

View authorizations

 for ' Tom '@'localhost';

Revoke authorization

 from ' User name '@' Source address ';

2) Database backup

Tables in the Backup library

Mysqldump-u root-p Library Name Table name 1 Table Name 2 > Backup path, Name

Backing up the entire library

Mysqldump-u root-p--database Library name 1 Library Name 2 > backup path, Name

Back up all databases

Mysqldump-u root-p--all-databases > Backup path, Name

3) Database Recovery

a)        Create a database with the same name in MySQL b)        restore command               -u root-p Library name < backup path, name

Teaches you how to play MySQL in 3 minutes

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.