Posts

Showing posts from 2015

Set auto increment value in MySQL

ALTER TABLE table_name AUTO_INCREMENT = value ;

Check free disk space in Linux

df -h df -h /path/to/dir

Checking disk space usage

du - kscx *

Start/Stop MySQL Server on CentOS

Stop MySQL Server # /etc/init.d/mysqld stop Start MySQL Server # /etc/init.d/mysqld start Restart MySQL Server # /etc/init.d/mysqld restart

Apcahe configuration file location in CentOS

Get the path of running Apache: ps -ef | grep apache Append -V argument to the path Configuration file is SERVER_CONFIG_FILE under HTTPD_ROOT directory

Show column names in alphabetical order

SELECT c . column_name FROM INFORMATION_SCHEMA . COLUMNS c WHERE c . table_name = 'tbl_name' -- AND c.table_schema = 'db_name' ORDER BY c . column_name

How to see all foreign keys reference to a table column?

select   TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where   REFERENCED_TABLE_NAME = 'table_name'

Restart Apache in CentOS

apachectl restart     or   /sbin/service httpd restart

Sort SHOW COLUMNS or DESCRIBE TABLE

select COLUMN_NAME as 'Field' , COLUMN_TYPE as 'Type' , IS_NULLABLE as 'Null' , COLUMN_KEY as 'Key' , COLUMN_DEFAULT as 'Default' , EXTRA as 'Extra' from INFORMATION_SCHEMA . COLUMNS where TABLE_NAME = 'table' and TABLE_SCHEMA = 'database' -- add ordering -- order by Type ;

Count number of distinct occurrences

select column_name, count(*) from table_name group by column_name order by count(*) desc;

Installing RPM on CentOS

RPM packages typically have file names like foo-1.0-1.i386.rpm . The file name includes the package name ( foo ), version ( 1.0 ), release ( 1 ), and architecture ( i386 ). To install a package, log in as root and type the following command at a shell prompt: rpm -Uvh foo-1.0-1.i386.rpm

Check Services listening on which interface and port

netstat -tulpn