Common mysql database (table) Command

Connection: mysql -h host address -u user name -p User password (Note: u and the root can not have spaces, the other is the same) 
off: exit (Enter) 

to create the authorization: grant select on database * to user name. @ login host identified by \ "password \" 
to change the password: mysqladmin -u username -p password old password new password 
. delete authorization: revoke select, insert, update,  delete om * * from test2 @ localhost;

display databases: show databases ; 
display data tables: show tables; 
display table structure: describe table name; 

create a library: create database library name; 
delete database: drop database database name; 
use the library (check the library): use the library name; 

create a table: create table table name (field set list); 
delete tables: drop table table name; 
modify table: alter table rename t2 t1 
lookup table: select * from table name; 
empty table: delete from table name; 
backup table: mysqlbinmysqldump -h (ip) - uroot -p (password) databasename tablename>  tablename.sql
Recovery Table: mysqlbinmysql -h (ip) -uroot -p (password) databasename tablename <tablename.sql ( first operation before the original table deletion) 

increasing column: ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD INDEX (c)
modify columns: ALTER TABLE t2 mODIFY a TINYINT NOT  NULL, CHANGE bc CHAR (20);
delete column: ALTER TABLE t2 DROP cOLUMN c; 

backup database: mysql \ bin \ mysqldump -h ( ip) -uroot -p (password) databasename> database.sql 
restore the database: mysql \ bin \ mysql -h (  ip) -uroot -p (password) databasename <database.sql
replicate databases: mysql \ bin \ mysqldump --all-  databases> all-databases.sql
repair database: mysqlcheck -A -o -uroot -p54safer 

text data import: load data local infile \ "filename \" into table name; 

data import and export: mysql \ bin \ mysqlimport database tables.txt

Guess you like

Origin www.cnblogs.com/aifengguo/p/11202924.html