MySQL Learning---basic operational learning

Source: Internet
Author: User

1.1. Basic Operations

Database engine

Inodb: Support transactions [atomic operations, complete a number of column operations before the completion of the operation, otherwise rollback]

MyISAM: Supports full-text indexing, emphasizing fast read operations, primarily for high-load Select

To create a database, table:

show databases;  # view current MySQL has those data, the root directory has those folders create Datab  ASE database name;  # Create folder use database name;  # using the selected database, go to directory show tables;  # See those tables under the current database CREATE table name (nid int, name varchar, pwd varchar);  # CREATE DATABASE table select * from table name;  # View all data in the table insert into table name (NID, Name, pwd) VALUES (1, ' Alex ', ' 123 ');  # Insert Data select * FROM table name where id = 1;

User Management Special Commands:

Create user ' user ' username ' @ ' IP address ' identified by ' password '; Create users ' hhh ' @ ' 192.168.25.% ' identified by ' 777 ';  # Remote connection% indicates a wildcard delete user ' username ' @ ' IP address '; Modify User rename username ' @ ' IP address ' to ' new username ' @ ' IP address ', modify password Set password for ' username ' @ ' IP address ' = password (' new password ') flush privileges;  # command Immediate effect

Rights Management: Default None

Show grants for [email protected]; # View permissions grant all privileges on mysql.test to [email protected]ocalhost; # authorized Grant all privileges on Mysql.user to  [email protected] ' 192.168.25.% '; # REMOTE authorization Revoke all privileges on mysql.test fr Om [email protected]; # Right flush privileges;  # command Immediate effect

Remote connection:

Mysql-u root-h 192.168.25.100-p 3306–p

Database-level operations:

SHOW DATABASES; CREATE database name; CREATE database name DEFAULT CHARSET UTF8 COLLATE utf8_general_ci; Use database name; drop database name;

Table-Level actions:

Show tables; Desc tb1;drop table HHH;  # Delete Table Delete from hhh where id = 1; # Empty the table contents truncate TABLE HHH; # Empty the table, but keep the table frame select * from hhh;update hhh set sex = ' m ' WHERE id = 1;create Table HHH (    ID  int,    name varchar ( ),   sex  varchar (2))

Forgot Password:

# Start the mysqld--skip-grant-tables# client mysql-u root-p# Modify the user name Password update mysql.user set Authentication_string=password (' 666 ') where user= ' root '; flush privileges;

MySQL Learning---basic operational learning

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.