One, connect MySQL
localhost: mysql-h host address-u user name-P user Password
Remote host: mysql-h host ip-u user name-p user Password
Second, change the password
Mysqladmin-u username-p Old password password new password
Third, create the database
Create databases < database name >
Iv. displaying the database
Show databases
V. Deleting a database
Drop databases < database name >
Vi. Connecting the database
Use < database name >
Seven, select the current database
1. Display MySQL version: select version ();
2, display the current time: select Now ();
3, display date: SELECT dayofmonth (current_date);
4. Display string: Select "Welecome to my blog!";
5, when the calculator with :Select ((4 * 4)/10) + 25;
6. String Connection: Select CONCAT (F_name, "", L_name)
As Name
From Employee_data
where title = ' Marketing Executive ';
Viii. Creating a Database
CREATE table < table name > (< Field name 1> < type 1> [,.. < Field name N> < type n>]);
Example:mysql> create table MyClass (
> ID int (4) NOT NULL primary key auto_increment,
> Name char () NOT NULL,
> Sex int (4) NOT null default ' 0 ',
> Degree double (16,2));
Ix. Deleting a database
DROP table < table name >
X. Table Insert Data
INSERT into < table name > [(< Field name 1>[,.. < field name n >])] VALUES (value 1) [, (value N)]
Xi. querying data in a table
Select < Field 1, field 2,...> from < table name > where < expression >
Pagination is as follows: SELECT * FROM MyClass ORDER by ID limit 0, 2;
12: Delete data from a table
Delete from table name where expression
13: Modifying data in a table
Update table name Set field = new value,... WHERE condition
14: Add Field
alter table name add field type other;
Example:ALTER TABLE MyClass add passtest int (4) default ' 0 '
XV, modify the table name
Rename table name to new table name;
16. Querying all tables in the database
SELECTTABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERETABLE_SCHEMA = ‘数据库名
Reprinted from: http://www.cnblogs.com/zhangzhu/archive/2013/07/04/3172486.html
MySQL Common commands