Posts Tagged ‘command’

常用命令

March 4th, 2014

Linux

  • find /home -iname “*.log” -exec rm {} \;

    Delete file recursively by extension.

Windows

common used mysql commands

June 13th, 2010

start up & shut down mysql:

sudo /etc/init.d/mysql start;
sudo /etc/init.d/mysql stop;

or
sudo mysqladmin shutdown -p;

show db & tables:

show databases;
show tables;
desc tableName;

show the defination of a table:

show create table tableName;

show server status

SHOW FULL PROCESSLIST;
show status like ‘Conn%’;
show status like ‘%onn%’;
$ mysqladmin status

SHOW TABLE STATUS;

profile a query

EXPLAIN SELECT * FROM tableName;
or
SET profiling=1;
SELECT * FROM tableName;
...
SET profiling=0;
SHOW profiles;
SHOW profile for query 1;

Add a user

CREATE USER ‘nb’@'localhost’ IDENTIFIED BY ‘yourpassword’;
GRANT SELECT, INSERT, UPDATE, DELETE ON somedb.* TO ‘nb’@'localhost’;

show warnings

SHOW WARNINGS [LIMIT [offset,] row_count]
SHOW COUNT(*) WARNINGS

see: http://dev.mysql.com/doc/refman/5.5/en/show-warnings.html

Compress the result from mysqldump

Compress directly with gzip
mysqldump < mysqldump options> | gzip > outputfile.sql.gz

Gunzip and import using gzip
gunzip < outputfile.sql.gz | mysql < mysql options>

Compress directly with bzip2
mysqldump < mysqldump options> | bzip2 > outputfile.sql.bz2

Bunzip2 and import using bzip2
bunzip2 < outputfile.sql.bz2 | mysql < mysql options>

Compress directly with lzma
mysqldump < mysqldump options> | lzma > outputfile.sql.lzma

Unlzma and import using unlzma
unlzma < outputfile.sql.lzma | mysql < mysql options>

NOTE:

mysqldump < mysqldump options

can be replaced with:

mysqldump -hYourHost -uYourUserName -pYourPassword

reference: http://mediakey.dk/~cc/compressing-mysqldump-output-mysql-gzip-bzip2-and-lzma-7z/

even more…

please wait...