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