Thursday, March 13, 2014

Cannot find or open table wp_kstats_raw

This error usually occurs because the table has crashed or some other INNODB error. Usually its best to just recreate the table from scratch
DROP TABLE IF EXISTS `wp_kstats_raw`;
CREATE TABLE `wp_kstats_raw` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL,
  `ip` int(10) unsigned NOT NULL,
  `url` varchar(1024) NOT NULL,
  `referrer` varchar(1024) NOT NULL,
  `user_agent` varchar(1024) DEFAULT NULL,
  `os` varchar(255) DEFAULT NULL,
  `browser` varchar(255) DEFAULT NULL,
  `search_engine` varchar(255) DEFAULT NULL,
  `search_terms` varchar(255) DEFAULT NULL,
  `spider` varchar(255) DEFAULT NULL,
  `user` varchar(255) DEFAULT NULL,
  `preserved` enum('1') DEFAULT NULL,
  UNIQUE KEY `id` (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `ip` (`ip`),
  KEY `url` (`url`(255))

Monday, March 10, 2014

Thursday, February 13, 2014

Wednesday, January 29, 2014

How To Disable Eximstats on cPanel

Eximstats does just what it implies, keeps stats on exim(email). Sometimes you don't care about these stats and want to free your database and I/O up for more important things. Luckily you can via the following CLI command:
/usr/local/cpanel/bin/tailwatchd -–disable=Cpanel::TailWatch::Eximstats
You may want to truncate the related tables for eximstats in MySQL before doing this (to save time if they are crashed,etc) but is not required nor necessary as the above will clear the tables (but will bawk if they are crashed, etc)

Monday, January 20, 2014

PHP Function To Convert CIDR To Netmask

function cidr2mask($cidr) {
     return long2ip(-1 << (32 - (int)$cidr));

PHP Function To Convert Netmask To CIDR

function mask2cidr($mask){
     $long = ip2long($mask);
     $base = ip2long('');
     return 32-log(($long ^ $base)+1,2);     

Thursday, December 26, 2013

How To Fix [ERROR] Fatal error: Can't open and lock privilege tables: Table '' doesn't exist

Time to time on new installs of MySQL I encounter this error which is luckily very easy to fix.

From the command line simply run:
mysql_install_db --user=mysql
You may also encounter this error in part when trying to start/stop/restart the service and see:
ERROR! MySQL server PID file could not be found!
...which usually reveals itself in the err log in /var/lib/mysql