Blogs

PHP scripts for converting InnoDB to MyISAM database engine

This PHP CODE snippets will change your database engine from  InnoDB to MyISAM, this is useful when you need to save time manually changing all the tables from InnoDB to MyISAM, for example when a CMS populates a database with tables that use InnoDB but you cannot run on your web host because InnoDB is disabled and MyISAM is your remaining options.

Commonly on a shared hosting environments, web host disabled InnoDB because it requires more disk space and eats more Server resources and Memory than MyISAM. To use this scripts you need to change the variables:

dbServerName // Database server, commonly use value is localhost

dbUserName // Database User, the one with priveleges to your database

dbPassword // Password of the Database User

DatabaseName // The database you want to convert from InnoDB to MyISAM

Code

<?php
// display error is On for us to be notified if there's something wrong
ini_set('display_errors', 'On');
error_reporting(E_ALL);

// Set a connection for our database
$link = mysql_connect("dbServerName","dbUserName","dbPassword")
or die(
"unable to connect to msql server: " . msql_error());

// Select our database
mysql_select_db("DatabaseName", $link)
or die(
"unable to select database 'db': " . msql_error());

$result = mysql_query("show tables");
if (!
$result) {
  die(
'query failed: ');
}

// Use while loop to convert all tables to MyISAM
while ($row = mysql_fetch_array($result)){
// Command Reference: ALTER TABLE tableName ENGINE=MyISAM
mysql_query("ALTER TABLE ".$row[0]." ENGINE=MyISAM; ");
}

?>

How to install node.js in CentOS server

Here how to install node.js into you CentOS server. Login to your centOS server using SSH client such as putty and type the following commands in shell.

Code

yum install openssl-devel
cd /usr/local/src
wget http://nodejs.org/dist/v0.6.8/node-v0.6.8.tar.gz
tar zxvf node-v0.6.8.tar.gz
cd node-v0.6.8
./configure
make
make install

How to Install GMP Math library in CentOS server with WHM/CPANEL installation?

First log-in to your server through ssh access then follow this command or type these command in shell

wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.2.tar.bz2
tar -xjvf gmp-4.2.2.tar.bz2
cd gmp-4.2.2
./configure
make
make check
make install

nano /var/cpanel/easy/apache/rawopts/all_php5

add or type the following

--with-gmp

then recompile PHP with default settings

/scripts/easyapache

save and compile, follow the instructions until the scripts finish recompiling the PHP.
done!

How to install Drush in CentOS Linux for Drupal Development?

This command has been successfully tested on Debian, Ubuntu, CentOS and should work for most *NIX systems.

sudo wget --quiet -O - http://ftp.drupal.org/files/projects/drush-7.x-4.5.tar.gz | sudo tar -zxf - -C /usr/local/share
sudo ln -s /usr/local/share/drush/drush /usr/local/bin/drush
sudo drush

The last line is for Drush to auto download the required library. If it displays a list of drush command, it means drush was installed successfully.
Some machines might not have the right folders created, so either update the paths above to match your environment, or create them beforehand using this command.

sudo mkdir /usr/local/share/
sudo mkdir /usr/local bin/

How to create DRUPAL 7 sub theme


View more documents from Adolfo Nasol